I'm referring to the code of @karthik Prabhu in this question Issue using CCCrypt (CommonCrypt) in Swift who proposes solution to encrypt and decrypt strings in swift 2.0 i've copied, paste the code for encrypting and decrypting (using aes, 128 bit key size, ecb mode, pkcs7 paadding) strings in swift, howerver, while encryption works fine, decryprtion doesn't work, it outputs a totally different result, for example encrypting the string "test" returns the following "3fvaLg5IDlveswuXzhVQcw==" which is correct, but trying to decrypt such string returns the following "FZ70tZ4bjLmUgpL2hxiHfSDWglH/fw==" while it should obviuosly return the original string. Any idea what it can be?
Asked
Active
Viewed 292 times
0
-
Differently from the code above, I changed the key to be 1234567890123456 (128 bit) and i set keyLength = size_t(kCCKeySize128) instead of 256 – Se_sa93 Aug 31 '15 at 16:35
-
Your result looks very much like something that is base-64 encoded, and since your original isn't, it can't be the original. – gnasher729 Aug 31 '15 at 16:39