In dart how to decrypt of the encrypted value?

287 views
Skip to first unread message

Niyazi Toros

unread,
Jul 3, 2018, 7:48:00 AM7/3/18
to Dart Misc


I am testing the Cryptographic hashing functions for Dart.  I can't find any information about DECRYPTION?

Can anyone show me how to decryption of the encrypted value?


And this is example;


import 'dart:convert';
import 'package:crypto/crypto.dart';

void main() async {
 
var key = utf8.encode('p@ssw0rd');
 
var bytes = utf8.encode("Dart and Aqueduct makes my life easier. Thank you.");


 
// TODO: ENCRYPTION
 
var hmacSha256 = new Hmac(sha256, key); // HMAC-SHA256
 
var digest = hmacSha256.convert(bytes);
 
 
print(“————ENCRYPTION—————“);
 
print("HMAC digest as bytes: ${digest.bytes}");
 
print("HMAC digest as hex string: $digest");
 
print('\r\n');


 

 
// TODO: DECRYPTION

     
????????????
 
print(“————DECRYPTION—————“);
 
print(?????????);

}


Istvan Soos

unread,
Jul 3, 2018, 9:31:53 AM7/3/18
to General Dart Discussion, niyazi...@gmail.com
Hi Niyazi,

HMAC is not an encryption format that you can encrypt and decrypt, it
is a one-way hash function that can be used to check the integrity of
a message. You can only calculate the hash of a given message, but not
decrypt the message from the hash.

The wikipedia page explains it in more detail than I possibly can:
https://en.wikipedia.org/wiki/HMAC

package:crypto deals with hashes, it does not cover other types of cryptography.

Cheers,
Istvan
> --
> For more ways to connect visit https://www.dartlang.org/community
> ---
> You received this message because you are subscribed to the Google Groups
> "Dart Misc" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to misc+uns...@dartlang.org.
> To view this discussion on the web visit
> https://groups.google.com/a/dartlang.org/d/msgid/misc/0695244d-6df1-415c-9225-7c7fd26a9d12%40dartlang.org.

Niyazi Toros

unread,
Jul 3, 2018, 9:41:10 AM7/3/18
to Dart Misc
Thanks Istvan, there is a Chiper plugin but its to old and dint pass any documentation. I am looking something that encrypt string and than decrypt. In C# I do similar project but I am trying to find same in Dart.
Reply all
Reply to author
Forward
0 new messages