public string GetHash(string value) { try { var salt = GetSalt(); var plainTextBytes = Encoding.UTF8.GetBytes(value); var plainTextWithSaltBytes = new byte[plainTextBytes.Length + salt.Length]; for (var i = 0; i < plainTextBytes.Length; i++) { plainTextWithSaltBytes[i] = plainTextBytes[i]; } for (var i = 0; i < salt.Length; i++) { plainTextWithSaltBytes[plainTextBytes.Length + i] = salt[i]; } using (var sha512 = new SHA512Managed()) { var hashBytes = sha512.ComputeHash(plainTextWithSaltBytes); var hashWithSaltBytes = new byte[hashBytes.Length + salt.Length]; for (var i = 0; i < hashBytes.Length; i++) { hashWithSaltBytes[i] = hashBytes[i]; } for (var i = 0; i < salt.Length; i++) { hashWithSaltBytes[hashBytes.Length + i] = salt[i]; } var base64 = new KeyProvider(new Base64()); return(base64.Encrypt(hashWithSaltBytes)); } } catch { return(string.Empty); } }