Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Jagaa9a opened this issue Mar 31, 2020 · 1 comment
Open

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

Jagaa9a opened this issue Mar 31, 2020 · 1 comment

Comments

@Jagaa9a
Copy link

Jagaa9a commented Mar 31, 2020

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

@iosdevzone
Copy link
Owner

iosdevzone commented Jul 27, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants