LockBox Official website: http://lockbox.seanbdurkin.id.au/HomePage
Lockbox's GitHub website: https://github.com/SeanBDurkin/tplockbox
LockBox 3.7.0 Download: https://github.com/SeanBDurkin/tplockbox/archive/master.zip
Installation of LockBox3.7.0:
1, unzip the downloaded LockBox3.7.0 compression package, put everything inside the package into the directory you want to put, I put it in: "C:\DelphiLib\LockBox3.7.0".
2, add "C:\DelphiLib\LockBox3.7.0\run" to your Delphi's "library". Click on the Menu "Tools", "Options", in the Pop-up dialog box, select "Delphi Options" on the left, "library", then click on the right "library path" below the right button, then add the above directory. Note: This directory is my own place to store LockBox3.7.0, you should be replaced by your own LockBox3.7.0 to store the corresponding directory!
3, compile and install LockBox3.7.0.
A, open your use of Delphi corresponding to the run-time engineering directory, I use the Delphi XE8, the corresponding directory is "C:\DelphiLib\LockBox3.7.0\packages\XE8", then the project group files directly into the Delphi XE8 inside.
B, right mouse button engineering group, then click on the Right menu "Build all".
Note: If this time error, see the wrong keyword, I first compile time error, this keyword is not correct, then I add the above path to the library, once again compiled, found that the keyword was modified wrong, correct into the correct Delphi keyword can be. I listed the error condition that I had, that is, the keyword was tampered with!!
C, install lockbox, right mouse button "DCLTP_LOCKBOX3_XE8.BPL", click "Install", if everything goes well, you should install on it.
Until now, we have successfully installed the LockBox3.7.0, if you do not modify the previous version of lockbox code, the direct use of no problem, if you want to modify the previous version lockbox code, a lot of problems, first look at the problem, then I tell you how to solve!!
Error:
Workaround:
1. Look at the name of the DCU file in the "C:\DelphiLib\LockBox3.7.0\work-products\ephemeral\dcu\XE8\Win32" directory and find it "TPLB3. CODEC.DCU "In this format, and Delphi is currently the latest unit name is not the same?
2. Modify all the wrong unit filenames to "TPLB3." + The unit file name after the original underline, for example: the original unit filename "Utplb_signatory", modified to "TPLB3." Signatory ", immediately error disappears, always follow this method to modify all errors, and then compile, completely correct!
Examples of cryptographic decryption demos:
Complete example Download: http://download.csdn.net/detail/sunylat/9728033
unit Unit1;
interface
uses
Winapi.Windows , Winapi.Messages , System.SysUtils , System.Variants ,
System.Classes , Vcl.Graphics ,
Vcl.Controls , Vcl.Forms , Vcl.Dialogs , Vcl.StdCtrls , Vcl.ExtCtrls ;
type
TForm2 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
clearLogBtn: TButton;
logMemo: TMemo;
Splitter1: TSplitter;
Panel3: TPanel;
Button2: TButton;
Memo1: TMemo;
Button1: TButton;
Memo2: TMemo;
procedure clearLogBtnClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
//Encrypted string
procedure EncryptString(keyStr, Plaintext: string; var CipherText: String);
//Decrypt string
procedure DecryptString(keyStr: string; var Plaintext: string;
CipherText: String);
public
{ Public declarations }
Procedure mylog (templog: String); / / log method
end;
const
Encryptkey ='lockboxkey '; / / the encryption and decryption key used in the test can be changed into any key you want
Var
Form2: TForm2;
LogInfo: string; / / log information
implementation
{$R *.dfm}
uses
TPLB3.Signatory, TPLB3.Codec, TPLB3.BaseNonVisualComponent,
TPLB3.CryptographicLibrary, TPLB3.Constants;
//Encrypted string
procedure TForm2.EncryptString(keyStr, Plaintext: string;
var CipherText: String);
Var
Codec2: TCodec;
CryptographicLibrary2: TCryptographicLibrary;
begin
Try
Codec2 := TCodec.Create (nil);
CryptographicLibrary2 := T CryptographicLibrary.Create (nil);
Codec2.CryptoLibrary := CryptographicLibrary2;
//This is the key to how dynamic object creation works
Codec2.StreamCipherId := TPLB3. Constants.BlockCipher_ ProgId;
Codec2.BlockCipherId := TPLB3. Constants.DES_ ProgId;
Codec2.ChainModeId := TPLB3. Constants.ECB_ ProgId;
//Set password
Codec2.Password := Trim(keyStr);
//Encrypted string
Codec2.EncryptString(Plaintext, CipherText, TEncoding.Default );
finally
Codec2.Free;
CryptographicLibrary2.Free;
end;
end;
//Decrypt string
procedure TForm2.DecryptString(keyStr: string; var Plaintext: string;
CipherText: String);
Var
Codec2: TCodec;
CryptographicLibrary2: TCryptographicLibrary;
begin
Try
Codec2 := TCodec.Create (nil);
CryptographicLibrary2 := T CryptographicLibrary.Create (nil);
Codec2.CryptoLibrary := CryptographicLibrary2;
//This is the key to how dynamic object creation works
Codec2.StreamCipherId := TPLB3. Constants.BlockCipher_ ProgId;
Codec2.BlockCipherId := TPLB3. Constants.DES_ ProgId;
Codec2.ChainModeId := TPLB3. Constants.ECB_ ProgId;
//Set password
Codec2.Password := Trim(keyStr);
//Encrypted string
Codec2.DecryptString(Plaintext, CipherText, TEncoding.Default );
finally
Codec2.Free;
CryptographicLibrary2.Free;
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
Var
Plaintext: string; / / unencrypted information variable
Ciphertext: string; / / encrypted information variable
begin
if Trim( logMemo.Text ) <> ‘‘ then
begin
//Get decrypted content
CipherText := Trim( logMemo.Text );
//Decryption
self.DecryptString (EncryptKey, Plaintext, CipherText);
//Display decrypted content
Memo2.Text := Plaintext;
if Trim(Memo1.Text) <> ‘‘ then
begin
if Trim(Memo1.Text) = Trim(Memo2.Text) then
begin
Show message ("decryption is correct!! ‘);
End
else
begin
Showmessage ("the decryption result is inconsistent with the content before encryption)!!! ‘);
end;
end;
End
else
begin
Showmessage ("sorry, the decryption content cannot be empty! ‘);
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
Var
Plaintext: string; / / unencrypted information variable
Ciphertext: string; / / encrypted information variable
begin
//To encrypt information
Plaintext := Trim(Memo1.Text);
if Plaintext = ‘‘ then
begin
Showmessage ("sorry, the content to be encrypted cannot be empty! ‘);
End
else
begin
//Encryption
self.EncryptString (EncryptKey, Plaintext, CipherText);
//Display encrypted information
logMemo.Text := CipherText;
end;
end;
procedure TForm2.clearLogBtnClick(Sender: TObject);
begin
logMemo.Clear ;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
end;
//Log method
procedure TForm2.MyLog(tempLog: string);
Var
temp: string;
oldLog: string;
begin
if Trim(tempLog) <> ‘‘ then
begin
oldLog := Trim( logMemo.Text );
logMemo.Clear ;
temp := FormatDateTime(‘yyyy-mm-dd hh:mm:ss‘, now) + ‘ ‘ + Trim(tempLog);
if oldLog = ‘‘ then
begin
logMemo.Lines.Add (temp);
logMemo.Lines.Add (‘‘);
End
else
begin
logMemo.Lines.Add (temp);
logMemo.Lines.Add (‘‘);
logMemo.Lines.Add (oldLog);
end;
end;
end;
end.
Install lockbox 3.7.0, encrypt and decrypt with lockbox!