feat:日志查看
fix:真机bug
This commit is contained in:
1 parent
5b9ef49564
commit
6ef0b6320f
40 files changed
+2773
-198
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:pointycastle/export.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
@@ -7,4 +11,29 @@ class EncryptionTool {
|
||||
static String getLoginAuthorization() {
|
||||
return "Basic ${EncryptUtil.encodeBase64(Constants.oauth2AppClient)}";
|
||||
}
|
||||
|
||||
/// 按 Web 端约定使用 AES-CFB、Key 同值 IV、NoPadding 加密登录密码。
|
||||
static String encryptLoginPassword(String password) {
|
||||
final keyBytes = Uint8List.fromList(utf8.encode(Constants.pwdEncKey));
|
||||
final passwordBytes = Uint8List.fromList(utf8.encode(password));
|
||||
final cipher = AESEngine()..init(true, KeyParameter(keyBytes));
|
||||
final encrypted = Uint8List(passwordBytes.length);
|
||||
var feedback = Uint8List.fromList(keyBytes);
|
||||
|
||||
for (var offset = 0; offset < passwordBytes.length; offset += 16) {
|
||||
final streamBlock = Uint8List(16);
|
||||
cipher.processBlock(feedback, 0, streamBlock, 0);
|
||||
final blockLength = (passwordBytes.length - offset).clamp(0, 16).toInt();
|
||||
for (var index = 0; index < blockLength; index++) {
|
||||
encrypted[offset + index] =
|
||||
passwordBytes[offset + index] ^ streamBlock[index];
|
||||
}
|
||||
if (blockLength == 16) {
|
||||
feedback = Uint8List.fromList(
|
||||
encrypted.sublist(offset, offset + blockLength),
|
||||
);
|
||||
}
|
||||
}
|
||||
return base64Encode(encrypted);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user