 |
About ActiveCrypt |
 |
How to ... |
 |
Programmer reference |
 |
Hash |
 |
Methods |
 |
Properties |
 |
Crypt |
 |
Methods |
 |
Properties |
 |
Base64 |
 |
Methods |
 |
Properties |
 |
Sign |
 |
Methods |
 |
Properties |
 |
RSACrypt (old, use Crypt) |
 |
Methods |
 |
Properties |
 |
Events |
|
How to encrypt strings
ActiveCrypt makes the encryption of strings very easy. To do
this you must have the public key loaded in memory (created with theGenerateCouple or loaded with the LoadKey)
Example :
ActiveCryptObject.Async = False
CryptedString = ActiveCryptObject.PublicEncrypt(PublicKey, "Hello RSA!")
If ActiveCryptObject.Error <> ERR_OK then MsgBox "Error happened!"
|
If you don't want your application to be locked and wait until
the encryption is finished, you can use Async mode. In this case OnEncryptionFinised is fired when the encryption is
finished. You can also pass the Cookie identificator to find which event returns which
string. The Cookie is just any integer meaningful to you.
Here is an example:
ActiveCryptObject.Async = True
CryptedString1 = ActiveCryptObject.PublicEncrypt(PublicKey, "Hello RSA!", 12345)
CryptedString2 = ActiveCryptObject.PublicEncrypt(PublicKey, "Hello World!", 54321)
'in Async mode empty string returns immediately to CryptedString1 and CryptedString2
...
Sub ActiveCryptObject_OnEncryptionFinished(ByVal Cookie As Long, ByVal CryptedText As String)
ListBox1.AddItem "Cookie: "+Str(Cookie)+" "+CryptedText
End Sub
|
If you use the synchronous mode you don't need Cookies and
you may not pass them to PublicEncrypt. After the
decryption is doneOnDecryptionFinished event
is fired. For more information about decryption in asynchronous mode please read Async mode.
|