public static string Decrypt(string encryptedValue) {
			if (string.IsNullOrEmpty(encryptedValue)) {
				return string.Empty;
			}
	
			DataProtector protector = new DataProtector(DataProtector.Store.USE_MACHINE_STORE);
			byte[] cipherText = Convert.FromBase64String(encryptedValue);
			return Encoding.ASCII.GetString(protector.Decrypt(cipherText, null));
		}
		public static string Encrypt(string valueToEncrypt) {
			if (string.IsNullOrEmpty(valueToEncrypt)) {
				return string.Empty;
			}
			
			DataProtector protector = new DataProtector(DataProtector.Store.USE_MACHINE_STORE);
			byte[] bytes = Encoding.ASCII.GetBytes(valueToEncrypt);
			return Convert.ToBase64String(protector.Encrypt(bytes, null));
		}
示例#3
0
        public static string Decrypt(string encryptedValue)
        {
            if (string.IsNullOrEmpty(encryptedValue))
            {
                return(string.Empty);
            }

            DataProtector protector = new DataProtector(DataProtector.Store.USE_MACHINE_STORE);

            byte[] cipherText = Convert.FromBase64String(encryptedValue);
            return(Encoding.ASCII.GetString(protector.Decrypt(cipherText, null)));
        }
示例#4
0
        public static string Encrypt(string valueToEncrypt)
        {
            if (string.IsNullOrEmpty(valueToEncrypt))
            {
                return(string.Empty);
            }

            DataProtector protector = new DataProtector(DataProtector.Store.USE_MACHINE_STORE);

            byte[] bytes = Encoding.ASCII.GetBytes(valueToEncrypt);
            return(Convert.ToBase64String(protector.Encrypt(bytes, null)));
        }