Component for working with RSA cryptosystem (wiki).
Prerequirements
OS compatibility
7 SP2 x64 |
8 x64 |
8.1 x64 |
10 x64 |
11 x64 |
RAD Studio compatibility
10 Seattle |
10.1 Berlin |
10.2 Tokyo |
10.3 Rio |
10.4 Sydney |
11 Alexandria |
1 user
3 users
5 users
10 users
Site license
Free components in a bundle
Buy a bundle now and enjoy all new component releases for free during the update period. |
Keep track of multiple versions
You will get access to all older versions and a detailed changelog. |
Free new features
Get all new component features for free during the free update period. |
Install once use forever
Our products are not time limited. |
Source code promise
In case our component will become obsolete and we no longer support it, we will provide you its source code. So you don’t have to worry about a replacement. |
References:
> QSG code example provided with the installer
After installation, a group PyBridge will appear in the Tool Palette of Delphi, where you can find the new component TPBRSA
New component TPBRSA can be found in the Tool Palette under PyBridge group
Place TPBRSA onto the form and set up its main properties:
- OpenSSL – the path to the openssl.exe library file supplied as part of the component.
- PrivateKey – the private key to be used. Calling a “PBRSA1.GenerateKeys” command will fill this field automatically. In the trial version this value is predefined.
- PublicKey – the public key to be used. Calling a “PBRSA1.GenerateKeys” command will fill this field automatically. In the trial version this value is predefined.
Now PBRSA is ready to be used. To demonstrate how it works, let’s create a simple application for generating keys, encryption, and decryption.
Add the corresponding buttons and Memos to the form to display:
- generated keys: public and private
- the original text to be encoded
- code obtained by encryption using the public key
- text recovered using the private key
- error messages
PBRSA encryption / decryption application layout
Instead of manually entering both private and public keys you may use “PBRSA1.GenerateKeys” command somewhere in your code (e.g. with a separate button). Keys generated by “PBRSA1.GenerateKeys” command will overwrite the corresponding PBRSA1 object properties. If you have a trial version you don’t need to do this, as the keys are predefined.
1 2 3 |
PBRSA1.GenerateKeys; //no need if the trial version
PrivateKeyMemo.Text := PBRSA1.PrivateKey;
PublicKeyMemo.Text := PBRSA1.PublicKey;
|
Encode the message from the “Data To Crypt” field. For encoding, the key specified by the PBRSA1.PublicKey property is used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
procedure TRSADemo.PublicEncryptButtonClick(Sender: TObject); var ResultStr1, ResultStr2: AnsiString; ErrorMessage: String; begin CryptedDataMemo.Clear; DecryptedDataMemo.Clear; ErrorMemo.Clear; ResultStr1 := AnsiString(DataToCryptMemo.Text); if PBRSA1.PublickEncrypt(ResultStr1, ResultStr2, ErrorMessage) then begin CryptedDataMemo.Text := ResultStr2; astr := ResultStr2; end else begin ErrorMemo.Text := ErrorMessage; end; end; |
Decrypt the previously encoded message with the private key. For decoding, the key specified by the PBRSA1.PublicKey property is used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
procedure TRSADemo.PrivateDecryptButtonClick(Sender: TObject); var ResultStr1, ResultStr2: AnsiString; ErrorMessage: String; begin DecryptedDataMemo.Clear; ErrorMemo.Clear; ResultStr1 := astr; if PBRSA1.PrivateDecrypt(ResultStr1, ResultStr2, ErrorMessage) then begin DecryptedDataMemo.Text := ResultStr2; end else begin ErrorMemo.Text := ErrorMessage; end; end; |
Start the program, fill the “Data to Crypt” field with the text you want to encrypt and click the “Public Encrypt” button. A message encrypted with the “Public Key” will appear in the “Crypted Data” field.
Click the “Private Decrypt” button. A decrypted message will appear in the “Decrypted Data” field. Make sure that it matches the original.
This example demonstrates how you can easily and quickly generate RSA keys, perform encryption and decryption with a help of PBRSA component. Now you can also enjoy the full power of PBRSA in your applications!