Text encryption and decryption
Dim lResult As
Long
Dim sEncrypted As
String
Dim sDecrypted As String
' Fill sNew to force the string variable
to a sufficient size for the returned string (Max 1000)
sEncrypted = Space(1000)
' Encrypt the text
lResult = sEncryptText("Test to encrypt", sEncrypted,
"password", 1234567890, True)
If lResult = 0 Then
MsgBox "Text has been encrypted to
'" & sEncrypted & "'"
Else
MsgBox "Unable to encrypt text"
End If
' Decrypt the text
sDecrypted = Space(1000)
lResult = sDecryptText(sEncrypted, sDecrypted, "password",
1234567890, True)
If lResult = 0 Then
MsgBox "Text has been decrypted to
'" & sDecrypted & "'"
Else
MsgBox "Unable to decrypt text"
End If
File encryption and decryption
Dim lResult As
Long
' Encrypt a file
lResult = sEncryptFile("\My Documents\plain.txt", "\My
Documents\cipher.txt", "password", 1234567890, True)
If lResult = 0 Then
MsgBox "The file has been encrypted"
Else
MsgBox "Unable to encrypt file"
End If
' Decrypt a file
lResult = sDecryptFile("\My Documents\cipher.txt", "\My
Documents\decrypted.txt", "password", 1234567890,
True)
If lResult = 0 Then
MsgBox "The file has been decrypted"
Else
MsgBox "Unable to decrypt file"
End If
|