Beispiel #1
0
        public string DecryptText(string cipherText)
        {
            string[] cipherTexts     = cipherText.Split('$');
            var      rsaCrypto       = new RSACrypto(_key);
            var      key             = rsaCrypto.DecryptText(cipherTexts[1]);
            var      vector          = rsaCrypto.DecryptText(cipherTexts[2]);
            var      tripleDesCrypto = new TripleDESCrypto(key, vector);

            return(tripleDesCrypto.DecryptText(cipherTexts[0]));
        }
Beispiel #2
0
        public string EncryptText(string plainText)
        {
            var key             = TripleDESCrypto.CreateNewKey();
            var vector          = TripleDESCrypto.CreateNewVector();
            var tripleDesCrypto = new TripleDESCrypto(key, vector);
            var encryptedText   = tripleDesCrypto.EncryptText(plainText);
            var rsaCrypto       = new RSACrypto(_key);
            var encryptedKey    = rsaCrypto.EncryptText(key);
            var encryptedVector = rsaCrypto.EncryptText(vector);

            return(encryptedText + "$" + encryptedKey + "$" + encryptedVector);

            tripleDesCrypto = null;
        }