Beispiel #1
0
        string TestEncrypt(string plainText, string password)
        {
            var cryptorData = RNCryptor.Encrypt(password,
                                                CryptographicBuffer.ConvertStringToBinary(
                                                    plainText,
                                                    BinaryStringEncoding.Utf8).ToByteArray());

            return(CryptographicBuffer.EncodeToBase64String(cryptorData.GetBuffer().ToBuffer()));
        }
Beispiel #2
0
        void TestDecrypt(string cipherText, string password, string expectedPlainText)
        {
            var cryptorData     = RNCryptorData.FromBase64String(cipherText);
            var plainTextBuffer = RNCryptor.Decrypt(password, cryptorData);
            var plainText       = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8,
                                                                            plainTextBuffer.ToBuffer());

            System.Diagnostics.Debug.Assert(plainText == expectedPlainText);
        }