// s = '1234' private static string Encrypt(string s) { HashAlgorithm provider = null; try { provider = new SHA1Managed(); byte[] bytes = Encoding.Unicode.GetBytes(s); // bytes = 49, 0, 50, 0, 51, 0, 52, 0 provider.Initialize(); bytes = provider.ComputeHash(bytes); // bytes = 19, 519, 105, 201, 60, 4, 36, 150, 168, 233, 88, 236, 89, 48, 102, 44, 108, 204, 175, 191 return Convert.ToBase64String(bytes); // bytes = E59pyTwEJJao6VjsWTBmLGzMr78= } finally { if (provider != null) provider.Clear(); } }