Swift
Swift
Transition from RandomizeKey to GenRandomBytesENC
Provides instructions for replacing deprecated RandomizeKey method calls with GenRandomBytesENC.Chilkat Swift Downloads
func chilkatTest() {
let crypt = CkoCrypt2()!
crypt.cryptAlgorithm = "aes"
crypt.cipherMode = "cbc"
crypt.keyLength = 256
// ...
// ------------------------------------------------------------------------
// The RandomizeKey method is deprecated:
// Generates and sets a random 32-byte (256-bit) secret key.
crypt.randomizeKey()
// ------------------------------------------------------------------------
// Do the equivalent using GenRandomBytesENC followed by SetEncodedKey
crypt.encodingMode = "base64"
var randomKeyBase64: String? = crypt.genRandomBytesENC(numBytes: 32)
crypt.setEncodedKey(keyStr: randomKeyBase64, encoding: "base64")
}