Sample code for 30+ languages & platforms
Lianja

Transition from RandomizeKey to GenRandomBytesENC

Provides instructions for replacing deprecated RandomizeKey method calls with GenRandomBytesENC.

Chilkat Lianja Downloads

Lianja
loCrypt = createobject("CkCrypt2")

loCrypt.CryptAlgorithm = "aes"
loCrypt.CipherMode = "cbc"
loCrypt.KeyLength = 256
// ...

// ------------------------------------------------------------------------
// The RandomizeKey method is deprecated:

// Generates and sets a random 32-byte (256-bit) secret key.
loCrypt.RandomizeKey()

// ------------------------------------------------------------------------
// Do the equivalent using GenRandomBytesENC followed by SetEncodedKey

loCrypt.EncodingMode = "base64"
lcRandomKeyBase64 = loCrypt.GenRandomBytesENC(32)
loCrypt.SetEncodedKey(lcRandomKeyBase64,"base64")


release loCrypt