飞镖/扑动河豚CBC

时间:2019-04-13 10:04:25

标签: dart flutter blowfish cbc-mode

如何在Flutter / Dart中进行Blowfish CBC解密?我找不到任何支持它的库。

dbcrypt仅支持密码哈希,不支持cbc模式。

谢谢。

1 个答案:

答案 0 :(得分:1)

import 'package:encrypt/encrypt.dart' as encrypt;
import 'package:encrypt/encrypt.dart';

class _MyHomePageState extends State<MyHomePage> {

    final plainText = 'some plain text here';
    final key = encrypt.Key.fromUtf8('16 characters key');
    final iv = IV.fromLength(16);
    final encrypter = Encrypter(AES(key,mode: AESMode.cbc,padding: 'PKCS7'));
    final encrypted = encrypter.encrypt(plainText, iv: iv);
    final decrypted = encrypter.decrypt(encrypted, iv: iv);
    print(decrypted); 
    print(encrypted.base64);

pubspec.yaml:


dependencies:

  encrypt: ^4.0.0