Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Prng
string ls_SaltHex
string ls_SaltBase64

// 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..
loo_Prng = create oleobject
li_rc = loo_Prng.ConnectToNewObject("Chilkat.Prng")
if li_rc < 0 then
    destroy loo_Prng
    MessageBox("Error","Connecting to COM object failed")
    return
end if

ls_SaltHex = loo_Prng.GenRandom(16,"hex")
Write-Debug "16-byte salt as hex: " + ls_SaltHex

ls_SaltBase64 = loo_Prng.GenRandom(16,"base64")
Write-Debug "16-byte salt as base64: " + ls_SaltBase64


destroy loo_Prng