示例#1
0
        public static byte[] Encrypt_ECB(byte[] plainBytes, byte[] keyBytes)
        {
            SM4_Context ctx = new SM4_Context();

            SM4Base sm4 = new SM4Base();

            sm4.sm4_setkey_enc(ctx, keyBytes);
            byte[] encrypted = sm4.sm4_crypt_ecb(ctx, plainBytes);
            return(encrypted);
        }
示例#2
0
        public static byte[] Decrypt_CBC(byte[] plainBytes, byte[] keyBytes, byte[] ivBytes)
        {
            SM4_Context ctx = new SM4_Context();

            SM4Base sm4 = new SM4Base();

            sm4.sm4_setkey_dec(ctx, keyBytes);
            byte[] encrypted = sm4.sm4_crypt_cbc(ctx, ivBytes, plainBytes);
            return(encrypted);
        }