-
-
Save majindageta/2bbb1866a60717fa6c64f5ff2d8b280f to your computer and use it in GitHub Desktop.
Dart HMAC SHA 256 Example code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html'; | |
import 'dart:convert'; | |
import 'package:crypto/crypto.dart'; | |
void main() { | |
String secret = 'secret'; | |
String message = 'Message'; | |
List<int> secretBytes = utf8.encode(secret); | |
List<int> messageBytes = utf8.encode(message); | |
var hMacSha256 = new Hmac(sha256, secretBytes); | |
var hash = hMacSha256.convert(messageBytes); | |
// output to html page | |
querySelector('#hash').text = hash; | |
// hash => qnR8UCqJggD55PohusaBNviGoOJ67HC6Btry4qXLVZc= | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment