(Delphi ActiveX) Generate Salt in Hex or Base64 Format
Demonstrates how to generate a cryptographic salt value and get the result as hex or base64.
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
prng: TChilkatPrng;
saltHex: WideString;
saltBase64: WideString;
begin
// In cryptography, a salt is random data that is used as an additional input to a one-way function that "hashes" data, a password or passphrase.
// Let's say we want to generate a 16-byte salt value..
prng := TChilkatPrng.Create(Self);
saltHex := prng.GenRandom(16,'hex');
Memo1.Lines.Add('16-byte salt as hex: ' + saltHex);
saltBase64 := prng.GenRandom(16,'base64');
Memo1.Lines.Add('16-byte salt as base64: ' + saltBase64);
end;
|