IDZSwiftCommonCrypto icon indicating copy to clipboard operation
IDZSwiftCommonCrypto copied to clipboard

algorithm: .tripleDES, mode: .CBC is not working proper.

Open Jagaa9a opened this issue 4 years ago • 1 comments

Hello @iosdevzone,

I am working on iOS swift project that encrypts and decrypts transfer data with TDES 2key CBC algorithm. Luckily, I found your repo and tried to implement it for my project. Below is my testing crypto code.

` import Foundation import IDZSwiftCommonCrypto

let algorithm = Cryptor.Algorithm.tripleDES let iv = arrayFrom(hexString: "00000000000000000000000000000000") let key = arrayFrom(hexString: "6522B4E171195BB218223A976C040111")

let cryptor = Cryptor(operation: .encrypt, algorithm: .tripleDES, mode: .CBC, padding: .NoPadding, key: key, iv: iv) let cipherText = cryptor.update(arrayFrom(hexString: "11223344556677885A6E7E385162B7A3404142434445464748494A4B4C4D4E4F"))?.final() `

It is working without error but the result is not right! I was expecting

937745c20883a1bad1e04193722a1592378f81a8f1dc589157aeb0f7544fa1ba

But Its result is

669747ad72be1037380ea630796ce9e974d7433a1ff05f923f51718cadf95d80 Can you help us to solve this problem?

Xcode 11.4 (11E146) Playground Settings iOS IDZSwiftCommonCrypto 0.13.0

Jagaa9a avatar Mar 31 '20 09:03 Jagaa9a

Apologies, I've been away from GitHub and have just seen this now. Did you solve your problem?

In the code above the key size is incorrect for 3DES are you sure you copied it into the issue correctly? Also could you provide some information about how you decided what the correct result should be.

Thanks.

iosdevzone avatar Jul 27 '20 17:07 iosdevzone