コード例 #1
0
        /// <summary>
        /// Decrpyt data from the database (Two way encryption)
        /// </summary>
        /// <param name="encrpytedData">Data to be decrypted</param>
        /// <param name="encryptionPass">Encrpyption password</param>
        /// <param name="isSearchTerm">Is this a database search term?</param>
        /// <returns></returns>
        public static string DecrpytData(string encrpytedData, string encryptionPass, bool isSearchTerm = false)
        {
            if (isSearchTerm)
            {
                return(AESTwoWayEncryption.Decrypt <TripleDESCryptoServiceProvider>(encrpytedData, encryptionPass, defaultSALT));
            }

            string salt      = encrpytedData.Substring(0, 8);
            string toDecrypt = encrpytedData.Substring(8, encrpytedData.Count() - 8);

            return(AESTwoWayEncryption.Decrypt <TripleDESCryptoServiceProvider>(toDecrypt, encryptionPass, salt));
        }
コード例 #2
0
        /// <summary>
        /// Decrypt file into original file contents
        /// </summary>
        /// <param name="fileContents">Original file contents</param>
        /// <param name="encryptionPassword">Encryption password</param>
        public static string[] DecryptFile(string[] encryptedContents, string encrpytionPassword)
        {
            string encryptionString = CombineStringArray(encryptedContents);

            string[] parts = encryptionString.Split(new string[] { "|SSPP|" }, StringSplitOptions.None); //Split encrypted data to get string and main contents
            string   salt  = parts[0];

            string decrpytedData = AESTwoWayEncryption.Decrypt <TripleDESCryptoServiceProvider>(parts[1], encrpytionPassword, salt);

            string[] seperatedString = decrpytedData.Split(new string[] { "@NL#" }, StringSplitOptions.None); //Split string back up into original lines
            return(seperatedString);
        }