(Swift) Transition from RandomizeKey to GenRandomBytesENC
Provides instructions for replacing deprecated RandomizeKey method calls with GenRandomBytesENC. Note: This example requires Chilkat v11.0.0 or greater.
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(32)
crypt.setEncodedKey(randomKeyBase64, encoding: "base64")
}
|