Sample code for 30+ languages & platforms
Delphi DLL

Generate Salt in Hex or Base64 Format

See more Encryption Examples

Demonstrates how to generate a cryptographic salt value and get the result as hex or base64.

Chilkat Delphi DLL Downloads

Delphi DLL
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Prng;

...

procedure TForm1.Button1Click(Sender: TObject);
var
prng: HCkPrng;
saltHex: PWideChar;
saltBase64: PWideChar;

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 := CkPrng_Create();

saltHex := CkPrng__genRandom(prng,16,'hex');
Memo1.Lines.Add('16-byte salt as hex: ' + saltHex);

saltBase64 := CkPrng__genRandom(prng,16,'base64');
Memo1.Lines.Add('16-byte salt as base64: ' + saltBase64);

CkPrng_Dispose(prng);

end;