Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Hash Value in Flutter Using SHA256?

Hashing Value (String or Int OR etc...) in Flutter ## Heading ##

I have Value like "Almahery"

How to Hash in in SHA 256 ?

like image 420
Muhammad Ashraf Avatar asked May 17 '19 12:05

Muhammad Ashraf


1 Answers

  1. Import (Crypto) :

     import 'package:crypto/crypto.dart';
    
  2. Then add this code:

     var bytes1 = utf8.encode("Almahery");         // data being hashed
     var digest1 = sha256.convert(bytes1);         // Hashing Process
     print("Digest as bytes: ${digest1.bytes}");   // Print Bytes
     print("Digest as hex string: $digest1");      // Print After Hashing
    
like image 197
Muhammad Ashraf Avatar answered Nov 19 '22 11:11

Muhammad Ashraf