sm_crypto 1.0.3 copy "sm_crypto: ^1.0.3" to clipboard
sm_crypto: ^1.0.3 copied to clipboard

Chinese national encryption algorithm SM2, SM3, SM4. Can output hex string or hex List<int>.

SM_CRYPTO 国家加密算法Dart版本 #

Multiple encryption: #

  1. sm2 (coding)
  2. sm3
  3. sm4

Using #

SM3 #

String data = 'Hello! SM-CRYPTO @Greenking19';
String sm3Encrypt = SM3.encryptString(data);
print('👇 SM3 Encrypt Data:');
print(sm3Encrypt);

SM4 #

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');

SmHelper #

List<int> bytes = SmHelper.utf8ToBytes('@Greenking19');
String string = SmHelper.bytesToUtf8(bytes);
...

Installing #

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 it #

Now in your Dart code, you can use: #

import 'package:sm_crypto/sm_crypto.dart';
10
likes
150
pub points
74%
popularity

Publisher

unverified uploader

Chinese national encryption algorithm SM2, SM3, SM4. Can output hex string or hex List<int>.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

convert

More

Packages that depend on sm_crypto