Hashing Value (String or Int OR etc...) in Flutter ## Heading ##
I have Value like "Almahery"
How to Hash in in SHA 256 ?
Import (Crypto) :
import 'package:crypto/crypto.dart';
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
let you want convert apple to SHA256 String
import 'package:crypto/crypto.dart';
var appleInBytes = utf8.encode("apple");
String value = sha256.convert(appleInBytes);
print(value.toString());
|
|
\|/
result
===> "3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b"