本文整理汇总了C#中System.Security.Cryptography.SHA512Managed.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# SHA512Managed.Clear方法的具体用法?C# SHA512Managed.Clear怎么用?C# SHA512Managed.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.SHA512Managed
的用法示例。
在下文中一共展示了SHA512Managed.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HashEncoding
/// <summary>
/// 哈希加密一个字符串
/// </summary>
/// <param name="Security"></param>
/// <returns></returns>
public static string HashEncoding(string Security)
{
byte[] Value;
SHA512Managed Arithmetic = null;
try
{
UnicodeEncoding Code = new UnicodeEncoding();
byte[] Message = Code.GetBytes(Security);
Arithmetic = new SHA512Managed();
Value = Arithmetic.ComputeHash(Message);
Security = "";
foreach (byte o in Value)
{
Security += (int)o + "O";
}
return Security;
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (Arithmetic!=null)
{
Arithmetic.Clear();
}
}
}
示例2: GetSHA512
/// <summary>
/// Genera el hash de la familia SHA2, SHA512 de la password en todo proceso de registro o logeo. El parámetro salt se suele dejar vacio, pues no se usa sal en esta aplicación.
/// </summary>
/// <param name="password"></param>
/// <param name="salt"></param>
/// <returns></returns>
public static string GetSHA512(string password, string salt)
{
System.Security.Cryptography.SHA512Managed HashTool = new System.Security.Cryptography.SHA512Managed();
Byte[] PasswordAsByte = System.Text.Encoding.UTF8.GetBytes(string.Concat(password, salt));
Byte[] EncryptedBytes = HashTool.ComputeHash(PasswordAsByte);
HashTool.Clear();
return BitConverter.ToString(EncryptedBytes);
}
示例3: CreateSHA2512Hash
public static string CreateSHA2512Hash(string phrase)
{
var HashTool = new SHA512Managed();
Byte[] PasswordAsByte = Encoding.UTF8.GetBytes(phrase);
Byte[] EncryptedBytes = HashTool.ComputeHash(PasswordAsByte);
HashTool.Clear();
return Convert.ToBase64String(EncryptedBytes);
}
示例4: CreateShaHash
/// <summary>
/// Create SHA2 hash
/// </summary>
/// <param name="phrase"></param>
/// <returns></returns>
public static string CreateShaHash(string[] phrase)
{
var hashTool = new SHA512Managed();
var phraseAsByte = Encoding.UTF8.GetBytes(string.Concat(phrase));
var encryptedBytes = hashTool.ComputeHash(phraseAsByte);
hashTool.Clear();
return BitConverter.ToString(encryptedBytes);
}
示例5: CreateSHAHash
public static byte[] CreateSHAHash(string Phrase)
{
SHA512Managed HashTool = new SHA512Managed();
Byte[] PhraseAsByte = System.Text.Encoding.UTF8.GetBytes(string.Concat(Phrase));
Byte[] EncryptedBytes = HashTool.ComputeHash(PhraseAsByte);
HashTool.Clear();
return EncryptedBytes;
}
示例6: SHA512Encrypt
/// <summary>
/// SHA512加密
/// </summary>
/// <param name="insertStr"></param>
/// <returns></returns>
public static string SHA512Encrypt(string insertStr)
{
byte[] tmpByte;
SHA512 sha512 = new SHA512Managed();
tmpByte = sha512.ComputeHash(GetKeyByteArray(insertStr));
sha512.Clear();
return GetStringValue(tmpByte);
}
示例7: CreateSHAHash
public static string CreateSHAHash(string Password, string Salt)
{
System.Security.Cryptography.SHA512Managed HashTool = new System.Security.Cryptography.SHA512Managed();
Byte[] PasswordAsByte = System.Text.Encoding.UTF8.GetBytes(string.Concat(Password, Salt));
Byte[] EncryptedBytes = HashTool.ComputeHash(PasswordAsByte);
HashTool.Clear();
return Convert.ToBase64String(EncryptedBytes);
}
示例8: CreateShaHash
public static string CreateShaHash(string password)
{
using (var hashTool = new SHA512Managed())
{
byte[] passwordAsByte = Encoding.ASCII.GetBytes(password);
byte[] encryptedBytes = hashTool.ComputeHash(passwordAsByte);
hashTool.Clear();
return BitConverter.ToString(encryptedBytes).Replace("-", "").ToLowerInvariant();
}
}
示例9: SHA512Compute
public static byte[] SHA512Compute(Stream stream)
{
if (stream == null)
throw new ArgumentNullException("stream");
SHA512Managed SHA512 = new SHA512Managed();
byte[] hash = SHA512.ComputeHash(stream);
SHA512.Clear();
return hash;
}
示例10: FromString
public static string FromString(string input, HashType hashtype)
{
Byte[] clearBytes;
Byte[] hashedBytes;
string output = String.Empty;
switch (hashtype)
{
case HashType.RIPEMD160:
clearBytes = new UTF8Encoding().GetBytes(input);
RIPEMD160 myRIPEMD160 = RIPEMD160Managed.Create();
hashedBytes = myRIPEMD160.ComputeHash(clearBytes);
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.MD5:
clearBytes = new UTF8Encoding().GetBytes(input);
hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.SHA1:
clearBytes = Encoding.UTF8.GetBytes(input);
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
sha1.ComputeHash(clearBytes);
hashedBytes = sha1.Hash;
sha1.Clear();
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.SHA256:
clearBytes = Encoding.UTF8.GetBytes(input);
SHA256 sha256 = new SHA256Managed();
sha256.ComputeHash(clearBytes);
hashedBytes = sha256.Hash;
sha256.Clear();
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.SHA384:
clearBytes = Encoding.UTF8.GetBytes(input);
SHA384 sha384 = new SHA384Managed();
sha384.ComputeHash(clearBytes);
hashedBytes = sha384.Hash;
sha384.Clear();
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.SHA512:
clearBytes = Encoding.UTF8.GetBytes(input);
SHA512 sha512 = new SHA512Managed();
sha512.ComputeHash(clearBytes);
hashedBytes = sha512.Hash;
sha512.Clear();
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
}
return output;
}
示例11: GerarHashSha1ComSalt
public static string GerarHashSha1ComSalt(string senha)
{
senha = senha.Trim();
var HashTool = new SHA512Managed();
var PhraseAsByte = Encoding.UTF8.GetBytes(string.Concat(senha + SaltText));
var EncryptedBytes = HashTool.ComputeHash(PhraseAsByte);
HashTool.Clear();
return Convert.ToBase64String(EncryptedBytes);
}
示例12: GetSHA512WithSalt
public static string GetSHA512WithSalt(string strPassword, string strSalt)
{
string _strPasswordSalt = strPassword + strSalt;
SHA512Managed _objSha512 = new SHA512Managed();
byte[] _objTemporal = null;
string Retorno = string.Empty;
StringBuilder sb = new StringBuilder();
try
{
_objTemporal = System.Text.Encoding.UTF8.GetBytes(_strPasswordSalt);
_objTemporal = _objSha512.ComputeHash(_objTemporal);
for (int i = 0; i < _objTemporal.Length; i++)
{
sb.Append(_objTemporal[i].ToString("X2"));
}
}
finally { _objSha512.Clear(); }
return sb.ToString(); ;
}
示例13: CreatePasswordHash
public static string CreatePasswordHash(string _password, string _salt)
{
string saltAndPwd = String.Concat(_password, _salt);
SHA512 sha512 = new System.Security.Cryptography.SHA512Managed();
byte[] sha512Bytes = System.Text.Encoding.Default.GetBytes(saltAndPwd);
byte[] cryString = sha512.ComputeHash(sha512Bytes);
string hashedPwd = string.Empty;
for (int i = 0; i < cryString.Length; i++)
{
hashedPwd += cryString[i].ToString("X");
}
sha512.Clear();
sha512.Dispose();
return hashedPwd;
}
示例14: CreateShaHash
/// <summary>
/// Create SHA2 hash
/// </summary>
/// <param name="phrase"></param>
/// <param name="type"></param>
/// <returns></returns>
public static string CreateShaHash(string[] phrase, Constants.TypeConvertMD5 type)
{
var hashTool = new SHA512Managed();
var phraseAsByte = Encoding.UTF8.GetBytes(string.Concat(phrase));
var encryptedBytes = hashTool.ComputeHash(phraseAsByte);
hashTool.Clear();
var data = "";
switch (type)
{
case Constants.TypeConvertMD5.Bit:
data = BitConverter.ToString(encryptedBytes);
break;
case Constants.TypeConvertMD5.String:
data = Convert.ToBase64String(encryptedBytes);
break;
}
return data;
}
示例15: SHA512Encrypt
/// <summary>
/// SHA512加密,不可逆转
/// </summary>
private byte[] SHA512Encrypt(byte[] code)
{
System.Security.Cryptography.SHA512 s512 = new System.Security.Cryptography.SHA512Managed();
byte[] result = s512.ComputeHash(code);
s512.Clear();
return result;
}