I've downloaded Lockbox3 about a week ago and i can't use it, and i couldn't understand the demo because it's complex i couldn't get the codes i want from it, I'd like to use lockbox 3 AES-256 encryption to encrypt strings in Delphi.
How to use AES-256 encryption in lockbox 3 using delphi
16.8k Views Asked by kero At
2
There are 2 best solutions below
0
On
Sean Your example has at least one error if not more:
var
Plaintext, sReconstructedPlaintext: string;
base64Ciphertext: ansistring;
Plaintext should be sPLaintext.
Plus Delphi Sydney compiler flags an error 'Not enough actual parameters' on codec.EncryptString( sPlaintext, base64Ciphertext);
I think that uncle bob was having an off day. This is a great library but unfortunately it is let down by poor documentation. I have ploughed my way through the relevant units in order to make some progress but it is a shame that I have to do this in order to assess whether I want to use it - I am writing a textbook for the school's market.
The method and property names pretty much say it all. Here is a method which encrypts a string and then decrypts it back again, assuming you've setup the codec properties at design time, which are also self-describing.
Have another look at the demo program. The handler for Encrypt button, encrypts a file instead of a string. That aside, if you strip away the decorative fluff, like posting information to a memo, and handling exceptions if the user specified a non-existant file, its increddibly simple - it basically boils down to one line...
To encrypt a string, you call EncryptString(). To encrypt a file you call EncryptFile().
The demo shows the setup, to wit:
and Bob's your uncle!
Let me know if you have any problems.