Example #1
0
        public string Encrypt(string text, SheetCrypting algorithm)
        {
            if (algorithm == SheetCrypting.Algo1)
            {
                return(Base64Encode(computeXor(text, Password)));
            }
            if (algorithm == SheetCrypting.Algo2)
            {
                return(Base64Encode(text));
            }

            return(text);
        }
Example #2
0
        /// <summary>
        /// Decrypts the specified text.
        /// </summary>
        /// <param name="text">The input string to decrypt.</param>
        /// <returns>The decrypted value of the specified input.</returns>
        public string Decrypt(string text, SheetCrypting algorithm)
        {
            switch (algorithm)
            {
            case SheetCrypting.Algo1:
                var b64Decoded = Base64Decode(text);
                var r          = computeXor(b64Decoded, Password);
                return(r);

            case SheetCrypting.Algo2:
                return(Base64Decode(text));
            }
            return(text);
        }
Example #3
0
 private static string cryptoToStr(string crypted, SheetCrypting algorithm)
 {
     return(string.IsNullOrWhiteSpace(crypted)
         ? string.Empty
         : Encryption.Instance.Decrypt(crypted, algorithm));
 }