Activecrypt Online Help Prev Next
About ActiveCrypt
About
ActiveCrypt overview
How to ...
How to make pair of keys
Create new public key from private
How to decrypt string
How to encrypt string
How to save keys
Free keys
Programmer reference
Hash
Hash overview
Methods
HashFile
HashVariant
Properties
Error
Crypt
Encryption overview
Methods
DecryptFile
DecryptVariant
EncryptFile
EncryptVariant
FreeKey
LoadKeyFromString
LoadKey
Properties
AddCRLF
Error
KeySize
Base64
Base64 overview
Methods
DecodeFile
DecodeVariant
EncodeFile
EncodeVariant
Properties
AddCRLF
Error
Sign
Sign overview
Methods
FreeKey
LoadKey
LoadKeyFromString
MakeVariantSignature
MakeFileSignature
VerifyFileSignature
VerifyVariantSignature
Properties
AddCRLF
Error
RSACrypt (old, use Crypt)
Methods
FreeKey
GenerateCouple
GeneratePublicKey
GetVersion
LoadKeyFromString
LoadKey
PublicEncrypt
PrivateDecrypt
SaveKeyToString
SaveKey
Properties
About
Async
Error
Events
OnDecryptionFinished
OnEncryptionFinished
OnError
OnKeyGenerationFinished
Disclaimer

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.

This HTML Help has been published using the chm2web software.