DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoPrng
String sSaltHex
String sSaltBase64
// 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..
Get Create (RefClass(cComChilkatPrng)) To hoPrng
If (Not(IsComObjectCreated(hoPrng))) Begin
Send CreateComObject of hoPrng
End
Get ComGenRandom Of hoPrng 16 "hex" To sSaltHex
Showln "16-byte salt as hex: " sSaltHex
Get ComGenRandom Of hoPrng 16 "base64" To sSaltBase64
Showln "16-byte salt as base64: " sSaltBase64
End_Procedure