- sm2 (coding)
- sm3
- sm4
String data = 'Hello! SM-CRYPTO @Greenking19';
String sm3Encrypt = SM3.encryptString(data);
print('👇 SM3 Encrypt Data:');
print(sm3Encrypt);
String key = SM4.createHexKey(key: '1234567890987654');
String data = 'Hello! SM-CRYPTO @greenking19';
print('👇 ECB Encrypt Mode:');
String ebcEncryptData = SM4.encrypt(data: data, key: key);
print('🔒 EBC EncryptptData:\n $ebcEncryptData');
String ebcDecryptData = SM4.decrypt(data: ebcEncryptData, key: key);
print('🔑 EBC DecryptData:\n $ebcDecryptData');
print('👇 CBC Encrypt Mode:');
String iv = SM4.createHexKey(key: '1234567890987654');
String cbcEncryptData = SM4.encrypt(
data: data,
key: key,
mode: SM4CryptoMode.CBC,
iv: iv,
);
print('🔒 CBC EncryptptData:\n $cbcEncryptData');
String cbcDecryptData = SM4.decrypt(
data: cbcEncryptData,
key: key,
mode: SM4CryptoMode.CBC,
iv: iv,
);
print('🔑 CBC DecryptData:\n $cbcDecryptData');
List<int> bytes = SmHelper.utf8ToBytes('@Greenking19');
String string = SmHelper.bytesToUtf8(bytes);
...
With Dart:
dat pub add sm_crypto
With Flutter:
flutter pub add sm_crypto
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get):
dependencies:
sm_crypto: ^1.0.3
import 'package:sm_crypto/sm_crypto.dart';