Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

Transition from RandomizeKey to GenRandomBytesENC

Provides instructions for replacing deprecated RandomizeKey method calls with GenRandomBytesENC.

Chilkat Xbase++ Downloads

Xbase++
LOCAL oCrypt
LOCAL cRandomKeyBase64

oCrypt := CreateObject("Chilkat.Crypt2")

oCrypt:CryptAlgorithm := "aes"
oCrypt:CipherMode := "cbc"
oCrypt:KeyLength := 256
//  ...

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

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

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

oCrypt:EncodingMode := "base64"
cRandomKeyBase64 := oCrypt:GenRandomBytesENC(32)
oCrypt:SetEncodedKey(cRandomKeyBase64, "base64")

oCrypt:destroy()