VB6 – SHA-1 Hash and Base64 Encode

Private Sub Command1_Click()

    Dim crypt As New ChilkatCrypt2
    success = crypt.UnlockComponent("30-day trial")
    If (success = 0) Then
        MsgBox crypt.LastErrorText
        Exit Sub
    End If
    Dim plainText As String
    plainText = "To be SHA-1 hashed..."
    crypt.EncodingMode = "base64"
    ' Hash the string and base64-encode in 1-Step
    Text1.Text = crypt.HashStringENC(plainText)
    ' Now do it in 2-steps. Should produce the same results as for HashStringENC...
    ' Hash the string to get the raw hash bytes, then
    ' base64 encode:
    Dim hashBytes As Variant
    hashBytes = crypt.HashString(plainText)
    ' Now Base64 encode:
    Text2.Text = crypt.Encode(hashBytes, "base64")
End Sub