-
Notifications
You must be signed in to change notification settings - Fork 23
HamcSHA224 encryption error #235
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
Comments
It works for me: import 'dart:convert';
import 'package:crypto/crypto.dart' show Hmac, sha224;
void main() {
var key = utf8.encode('some key');
var content = utf8.encode('some content');
print('Key: ${base64.encode(key)}');
print('Content: ${base64.encode(content)}');
var hmac= Hmac(sha224,key);
var result = hmac.convert(content);
print(result);
} Prints:
When I plug those base64 encoded values into https://www.liavaag.org/English/SHA-Generator/HMAC/ I get
|
If I downgrade to import 'dart:convert';
import 'package:crypto/crypto.dart' show Hmac, sha224, Digest, Hash;
Digest hamcEncryption({String key, String content, Hash hash}) {
var bytes = utf8.encode(content);
var keyString = utf8.encode(key);
var hmac = Hmac(hash, keyString);
var digest = hmac.convert(bytes);
return digest;
}
void main() {
print(base64.encode(utf8.encode('1234')));
print(base64.encode(utf8.encode('foo')));
print("${hamcEncryption(key: "1234", content: "foo", hash: sha224)}");
} prints
Plugging those base64 values into the site results in the same digest as this library. Perhaps you did not input the same data in your tests. |
|
Thank you for your reply and wish you a happy work.
…------------------ 原始邮件 ------------------
发件人: "dart-lang/crypto" ***@***.***>;
发送时间: 2021年8月27日(星期五) 上午9:13
***@***.***>;
***@***.******@***.***>;
主题: Re: [dart-lang/crypto] HamcSHA224 encryption error (#121)
If I downgrade to 2.1.4 and adapt your example I also see a result that agrees with https://www.liavaag.org/English/SHA-Generator/HMAC/
import 'dart:convert'; import 'package:crypto/crypto.dart' show Hmac, sha224, Digest, Hash; Digest hamcEncryption({String key, String content, Hash hash}) { var bytes = utf8.encode(content); var keyString = utf8.encode(key); var hmac = Hmac(hash, keyString); var digest = hmac.convert(bytes); return digest; } void main() { print(base64.encode(utf8.encode('1234'))); print(base64.encode(utf8.encode('foo'))); print("${hamcEncryption(key: "1234", content: "foo", hash: sha224)}"); }
prints
MTIzNA== Zm9v 7bc4fa1501e9864400fe802b89fe71edda20104fa354232fce2d173f
Plugging those base64 values into the site results in the same digest as this library. Perhaps you did not input the same data in your tests.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
When I used HamcSHA224, I found that the results of encrypted and online encrypted websites were different. I found many encrypted websites to compare, and they were all the same.
crypto: ^2.1.4
Digest hamcEncryption({@required String key,@required String content, @required Hash hash}) { var bytes = utf8.encode(content); var keyString=utf8.encode(key); var hmac = Hmac(hash, keyString); var digest = hmac.convert(bytes); return digest; }
print("${hamcEncryption(key: "1234", content: "foo", hash: sha224)}");
The text was updated successfully, but these errors were encountered: