Flutter:encrypt插件 AES加密处理

1、pubspec.yaml导入插件

复制代码
cupertino_icons: ^1.0.8
# 密码加密
encrypt: 5.0.3

encrypt封装

js 复制代码
import 'package:encrypt/encrypt.dart';
/// 加密类
class EncryptUtil {
  static final EncryptUtil _instance = EncryptUtil._internal();
  factory EncryptUtil() => _instance;
  EncryptUtil._internal() {
    encrypter = Encrypter(AES(
      key,
      mode: AESMode.cbc,
      padding: 'PKCS7',
    ));
  }
  final key = Key.fromUtf8('aH5aH5bG0dC6aA3oN0cK4aU5jU6aK2lN');
  final iv = IV.fromUtf8('hK6eB4aE1aF3gH5q');
  late Encrypter encrypter;
  /// aes加密
  String aesEncode(String content) {
    final encrypted = encrypter.encrypt(content, iv: iv);
    return encrypted.base64;
  }
}

页面中使用

js 复制代码
// 加密后
var password = EncryptUtil().aesEncode(passwordController.text);
相关推荐
geats人山人海几秒前
java 4继承
java·开发语言
众链网络24 分钟前
Agent 的成本大头不在“写“,在“判断“:拆解专用决策模型的三层架构
java·开发语言·人工智能·微服务
周小董26 分钟前
[1371]jdk管理工具
java·开发语言
青春逝如流水39 分钟前
Java 中线程的创建方式:从基础到现代
java·开发语言·多线程·ai文章
Peregrine91 小时前
C++ - > 类和对象
java·c++·算法
2501_933923251 小时前
SpringCloud组件:Eureka服务注册与发现
java·开发语言·后端·spring cloud·eureka
Wang's Blog1 小时前
Java 中间件之 RabbitMQ 快速入门: SpringAMQP 消息转换器
java·中间件·java-rabbitmq
大龄秃头程序员2 小时前
Riverpod 深度解析:从响应式本质到最小可运行闭环
flutter
Re_zero2 小时前
一次 SSE 断流排查:PrintWriter 吞掉了我的 IOException
java·后端
默_笙2 小时前
🧀 让大模型的答案"流"出来:NestJS AI 模块 + SSE + RxJS 实战
javascript·人工智能