Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkPrngW.h>
void ChilkatSample(void)
{
HCkPrngW prng;
const wchar_t *saltHex;
const wchar_t *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..
prng = CkPrngW_Create();
saltHex = CkPrngW_genRandom(prng,16,L"hex");
wprintf(L"16-byte salt as hex: %s\n",saltHex);
saltBase64 = CkPrngW_genRandom(prng,16,L"base64");
wprintf(L"16-byte salt as base64: %s\n",saltBase64);
CkPrngW_Dispose(prng);
}