public static string Encrypt(string inputString) { if (string.IsNullOrEmpty(inputString)) return string.Empty; var encryptor = new DesEncryptor { InputString = inputString, EncryptKey = "TgQQk42O" }; encryptor.DesEncrypt(); return encryptor.OutString; }
private static string Encrypt(string inputString) { if (string.IsNullOrEmpty(inputString)) { return(string.Empty); } var encryptor = new DesEncryptor { InputString = inputString, EncryptKey = "TgQQk42O" }; encryptor.DesEncrypt(); return(encryptor.OutString); }
public static string EncodePassword(string password, EPasswordFormat passwordFormat, out string passwordSalt) { var retval = string.Empty; passwordSalt = string.Empty; if (passwordFormat == EPasswordFormat.Clear) { retval = password; } else if (passwordFormat == EPasswordFormat.Hashed) { passwordSalt = GenerateSalt(); var src = Encoding.Unicode.GetBytes(password); var buffer2 = Convert.FromBase64String(passwordSalt); var dst = new byte[buffer2.Length + src.Length]; Buffer.BlockCopy(buffer2, 0, dst, 0, buffer2.Length); Buffer.BlockCopy(src, 0, dst, buffer2.Length, src.Length); var algorithm = HashAlgorithm.Create("SHA1"); if (algorithm == null) { return(retval); } var inArray = algorithm.ComputeHash(dst); retval = Convert.ToBase64String(inArray); } else if (passwordFormat == EPasswordFormat.Encrypted) { passwordSalt = GenerateSalt(); var encryptor = new DesEncryptor { InputString = password, EncryptKey = passwordSalt }; encryptor.DesEncrypt(); retval = encryptor.OutString; } return(retval); }
public static string EncryptStringBySecretKey(string inputString, string secretKey) { if (string.IsNullOrEmpty(inputString)) { return(string.Empty); } var encryptor = new DesEncryptor { InputString = inputString, EncryptKey = secretKey }; encryptor.DesEncrypt(); var retval = encryptor.OutString; retval = retval.Replace("+", "0add0").Replace("=", "0equals0").Replace("&", "0and0").Replace("?", "0question0").Replace("'", "0quote0").Replace("/", "0slash0"); return(retval); }