Flutter md5 base64加密解密

1.更新pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter

  crypto: ^2.0.6
  1. md5加密:
import 'dart:convert';
import 'package:convert/convert.dart';
import 'package:crypto/crypto.dart';

// md5 加密
 static String string2Md5(String data) {
    var content = new Utf8Encoder().convert(data);
    var digest = md5.convert(content);
    return hex.encode(digest.bytes);
  }

3.base64加密解密:

/*
  * Base64加密
  */
  static String encodeBase64(String data){
    var content = utf8.encode(data);
    var digest = base64Encode(content);
    return digest;
  }

  /*
  * Base64解密
  */
  static String decodeBase64(String data){
    return String.fromCharCodes(base64Decode(data));
  }

你可能感兴趣的:(Flutter md5 base64加密解密)