skavinvarnan / Cross-Platform-AES

Simple cross-platform encryption and decryption using AES
MIT License
142 stars 70 forks source link

Sha256 with 24 length key SWIFT #14

Open lucianofedericoolmedo opened 5 years ago

lucianofedericoolmedo commented 5 years ago

Hi, I have this snippet of code working with a sha256 with 32 length key

let plainText :String = "this is my plain text" let key :String = "your key" let cryptLib = CryptLib() let iv = "5/LRE3jKOTCav8VB" let size = 32 let sha = cryptLib.sha256(key, length: size) let cipherText = cryptLib.encrypt(plainText.data(using: String.Encoding.utf8), key: sha, iv: iv) print(cipherText!.base64EncodedString()) let elem = cryptLib.decrypt(cipherText, key: sha, iv: iv) let salida = String.init(data: elem!, encoding: String.Encoding.utf8) print(salida!)

But when i change size = 24, it fails the decrypt, is there any way to make the decryption it work ?, i am in a proyect that needs a 24 length key.