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

class MD5 {
  late final String _hash;

  MD5(String input) {
    _hash = _encode(input);
  }

  /// 生成字符串的 MD5
  String _encode(String input) {
    var bytes = utf8.encode(input);
    var digest = md5.convert(bytes);
    return digest.toString();
  }

  @override
  String toString() => _hash;
}
