Skip to content

Commit

Permalink
修复:修复了配置中存在中文时会报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuingsmile committed Nov 23, 2022
1 parent 3430386 commit dc55e17
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/utils/sql_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MySqlUtils {
String encryptKey = passwordUser * 3;
String to_encrypt = data + "保密占位符";
DES3 des3CBC = DES3(key: encryptKey.codeUnits, mode: DESMode.CBC, iv: iv);
encrypted = des3CBC.encrypt(to_encrypt.codeUnits);
encrypted = des3CBC.encrypt(utf8.encode(to_encrypt));
String encryptedString = hex.encode(encrypted);
return encryptedString;
}
Expand All @@ -33,7 +33,7 @@ class MySqlUtils {
List<int> encrypted = hex.decode(encryptedString);
DES3 des3CBC = DES3(key: encryptKey.codeUnits, mode: DESMode.CBC, iv: iv);
decrypted = des3CBC.decrypt(encrypted);
String decryptedStr = String.fromCharCodes(decrypted);
String decryptedStr = utf8.decode(decrypted);
String to_remove = "保密占位符";
String decryptedString =
decryptedStr.substring(0, decryptedStr.length - to_remove.length);
Expand Down

0 comments on commit dc55e17

Please sign in to comment.