Sample code for 30+ languages & platforms
PowerBuilder

Transition from RandomizeKey to GenRandomBytesENC

Provides instructions for replacing deprecated RandomizeKey method calls with GenRandomBytesENC.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Crypt
string ls_RandomKeyBase64

loo_Crypt = create oleobject
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2")
if li_rc < 0 then
    destroy loo_Crypt
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

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

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

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

loo_Crypt.EncodingMode = "base64"
ls_RandomKeyBase64 = loo_Crypt.GenRandomBytesENC(32)
loo_Crypt.SetEncodedKey(ls_RandomKeyBase64,"base64")


destroy loo_Crypt