public class EncryptHashServicios { public EncryptHashServicios() { } #region SHA1 public static byte[] SHA1encrypt(string phrase) { return SHA1encrypt(1, phrase); } public static byte[] SHA1encrypt(int cycles, string phrase) { UTF8Encoding encoder = new UTF8Encoding(); SHA1CryptoServiceProvider sha1hasher = new SHA1CryptoServiceProvider(); byte[] hashedDataBytes = encoder.GetBytes(phrase); for (int i = 0; i < cycles; i++) hashedDataBytes = sha1hasher.ComputeHash(hashedDataBytes); return hashedDataBytes; } #endregion public static string byteArrayToStringHex(byte[] inputArray) { StringBuilder output = new StringBuilder(""); for (int i = 0; i < inputArray.Length; i++) { output.Append(inputArray[i].ToString("X2")); } return output.ToString(); } public static string byteArrayToStringBase64(byte[] inputArray) { return Convert.ToBase64String(inputArray); } }
for use this clase only do this.
pass the key string
byte[] arraykeyencrypted = EncryptHashServicios.SHA1encrypt(key); string keyencrypted= EncryptHashServicios.byteArrayToStringBase64(arraykeyencrypted);
byte[] arraykeyencrypted = EncryptHashServicios.SHA1encrypt(key); string
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: