Example #1
0
        public static string Encrypt(string input, EncryptionProvider provider, string keyContainerName)
        {
            string retVal = default(string);

            switch (provider)
            {
            case EncryptionProvider.DPAPI:
            {
                retVal = CipherEngine.Encrypt(input, provider, "");
                retVal = string.Format("[DPAPI]{0}[DPAPI]", retVal);
                break;
            }

            case EncryptionProvider.RSA:
            {
                retVal = CipherEngine.Encrypt(input, provider, keyContainerName);
                retVal = string.Format("[RSA-{0}]{1}[RSA-{0}]", keyContainerName, retVal);
                break;
            }
            }

            return(retVal);
        }
Example #2
0
        public static string Decrypt(string input)
        {
            string             retVal     = default(string);
            EncryptionProvider provider   = GetEncryptionProvider(input);
            string             cipherData = GetEncryptedText(input);

            switch (provider)
            {
            case EncryptionProvider.DPAPI:
            {
                retVal = CipherEngine.Decrypt(cipherData, provider, "");
                break;
            }

            case EncryptionProvider.RSA:
            {
                string keyContainerName = GetRsaKeyContainerName(input);
                retVal = CipherEngine.Decrypt(cipherData, provider, keyContainerName);
                break;
            }
            }

            return(retVal);
        }