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

outdated

Chinese national encryption algorithm SM2, SM3, SM4

SM_CRYPTO 国家加密算法Dart版本 #

Multiple encryption: #

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

Using #

SM4 #

void sm4Example() {
  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');
}

void main() {
  sm4Example();
}

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.0

Import it #

Now in your Dart code, you can use: #

import 'package:sm_crypto/sm_crypto.dart';
10
likes
0
pub points
76%
popularity

Publisher

unverified uploader

Chinese national encryption algorithm SM2, SM3, SM4

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

convert

More

Packages that depend on sm_crypto