35 lines
744 B
Dart
35 lines
744 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:crypto/crypto.dart';
|
|
|
|
class Hashing {
|
|
static String md5Hash(String input) {
|
|
var hash = md5.convert(utf8.encode(input)).bytes;
|
|
String x = "";
|
|
for (int byte in hash) {
|
|
x += byte.toRadixString(16).padLeft(2, '0');
|
|
}
|
|
|
|
return x;
|
|
}
|
|
|
|
static String sha1Hash(String input) {
|
|
var hash = sha1.convert(utf8.encode(input)).bytes;
|
|
String x = "";
|
|
for (int byte in hash) {
|
|
x += byte.toRadixString(16).padLeft(2, '0');
|
|
}
|
|
|
|
return x;
|
|
}
|
|
|
|
static String sha256Hash(String input) {
|
|
var hash = sha256.convert(utf8.encode(input)).bytes;
|
|
String x = "";
|
|
for (int byte in hash) {
|
|
x += byte.toRadixString(16).padLeft(2, '0');
|
|
}
|
|
|
|
return x;
|
|
}
|
|
}
|