Beispiel #1
0
 public string Decrypt(ref string passPhrase, string pHexStream)
 {
     try
     {
         var objSym = new Symmetric(Symmetric.Provider.Rijndael, true);
         var encryptedData = new Data();
         encryptedData.Hex = pHexStream;
         Data decryptedData = default(Data);
         decryptedData = objSym.Decrypt(encryptedData, new Data(passPhrase));
         return decryptedData.Text;
     }
     catch
     {
         return null;
     }
 }
Beispiel #2
0
        private string Encrypt(ref string passPhrase, string textToEncrypt)
        {
            if (passPhrase.Length > 16)
            {
                passPhrase = passPhrase.Substring(0, 16);
            }

            if (textToEncrypt.Trim().Length == 0)
            {
                //'the Text to encrypt not set!!!
                return string.Empty;
            }

            var skey = new Data(passPhrase);
            var sym = new Symmetric(Symmetric.Provider.Rijndael, true);
            Data encryptedData = sym.Encrypt(new Data(textToEncrypt), skey);
            return encryptedData.ToHex();
        }