LibAC-dart/lib/utils/Hashing.dart

35 lines
696 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);
}
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);
}
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);
}
return x;
}
}