Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL oPrng
LOCAL cSaltHex
LOCAL cSaltBase64

//  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..
oPrng := CreateObject("Chilkat.Prng")

cSaltHex := oPrng:GenRandom(16, "hex")
? "16-byte salt as hex: " + cSaltHex

cSaltBase64 := oPrng:GenRandom(16, "base64")
? "16-byte salt as base64: " + cSaltBase64

oPrng:destroy()