-
Notifications
You must be signed in to change notification settings - Fork 10
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
How to do CBC-PKCS7 and iv=MD5(key)? #23
Comments
Okay, so this is how you do this here: import 'package:steel_crypt/steel_crypt.dart';
var hash1 = HashCrypt('SHA-256');
var hash2 = HashCrypt('MD5');
var keyAES = hash1.hash(key); //If key is the same variable from your example
print(AesCrypt(keyAES, 'cbc', 'pkcs7').encrypt(pw); //if pw is the same variable from your example Lemme know if you have questions or issues. Closing this for now. |
@AKushWarrior |
@s349856186 whoops. The below should work. import 'package:steel_crypt/steel_crypt.dart';
var hash1 = HashCrypt('SHA-256');
var hash2 = HashCrypt('MD5');
var keyAES = hash1.hash(key); //If key is the same variable from your example
print(AesCrypt(keyAES, 'cbc', 'pkcs7').encrypt(pw, hash2.hash(key))); //if pw and key are the same variables from your example |
@AKushWarrior [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Invalid argument(s): Initialization vector must be the same length as block size |
@AKushWarrior |
Sorry, I wasn't monitoring this issue for some reason. I'll take a look... |
Ah. The problem is that AES uses UTF-16 codeunits, whereas HashCrypt() uses base64 encoding/decoding. This will be fixed in steel_crypt 2.0. Tune into #22 . |
Okay, what I said was not the problem at all. You should use the new "raw" classes, and just take the first 16 digits of the hash as the iv. |
I can't give you a concrete code example until you give me what encoding CryptoJS uses. |
I used JS encrypt as below:
CryptoJS.AES.encrypt(pw, SHA256(key), {iv:MD5(key), mode:CBC, padding:Pkcs7})
How to do use this crypt ? Thanks
The text was updated successfully, but these errors were encountered: