Пример #1
0
        public void EncryptDecrypt(string originalString, SM2Mode mode)
        {
            var encStr     = SM2EncryptionProvider.EncryptByPublicKey(originalString, PubKey, mode: mode);
            var decodedStr = SM2EncryptionProvider.DecryptByPrivateKey(encStr, PriKey, mode: mode);

            Assert.Equal(originalString, decodedStr);
        }
Пример #2
0
        public void EncryptDecryptWithGenKey(string originalString, SM2Mode mode)
        {
            var key        = SM2EncryptionProvider.CreateKey();
            var encStr     = SM2EncryptionProvider.EncryptByPublicKey(originalString, key.PublicKey, mode: mode);
            var decodedStr = SM2EncryptionProvider.DecryptByPrivateKey(encStr, key.PrivateKey, mode: mode);

            Assert.Equal(originalString, decodedStr);
        }