26 lines
667 B
Dart
26 lines
667 B
Dart
|
||
import 'package:dart_sm/dart_sm.dart';
|
||
import 'package:qhd_prevention/http/ApiService.dart';
|
||
import 'package:qhd_prevention/tools/tools.dart' hide C1C2C3;
|
||
|
||
class Encrypt {
|
||
static String? encrypt(String text) {
|
||
try {
|
||
final md5 = md5Hex(text);
|
||
// 尝试用 C1C2C3(Hutool 常见顺序)
|
||
final raw = SM2.encrypt(md5, ApiService.publicKey);
|
||
|
||
final encrypted = ensureC1Has04(raw);
|
||
print('encrypted:$encrypted');
|
||
return encrypted;
|
||
|
||
} catch (e) {
|
||
return null;
|
||
// return false;
|
||
}
|
||
}
|
||
static String decrypt(String codeText) {
|
||
final dec = SM2.decrypt(codeText, ApiService.privateKey);
|
||
return dec;
|
||
}
|
||
} |