//// NOTE: Leave out the finalizer altogether if this class doesn't //// own unmanaged resources itself, but leave the other methods //// exactly as they are. //~Encryption() //{ // // Finalizer calls Dispose(false) // Dispose(false); //} // The bulk of the clean-up code is implemented in Dispose(bool) protected virtual void Dispose(bool disposing) { if (disposing) { // Free managed resources. lock (MacProviderLock) { if (_MacProvider != null) { _MacProvider.Dispose(); _MacProvider = null; } } lock (RsaProviderLock) { if (_RsaProvider != null) { _RsaProvider.Dispose(); _RsaProvider = null; } } if (_RsaSignatureHashAlgorithm != null) { _RsaSignatureHashAlgorithm.Dispose(); _RsaSignatureHashAlgorithm = null; } } }
public static bool _Create_System_String( ) { //Parameters System.String algName = null; //ReturnType/Value System.Security.Cryptography.KeyedHashAlgorithm returnVal_Real = null; System.Security.Cryptography.KeyedHashAlgorithm returnVal_Intercepted = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.Security.Cryptography.KeyedHashAlgorithm.Create(algName); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.Security.Cryptography.KeyedHashAlgorithm.Create(algName); } catch (Exception e) { exception_Intercepted = e; } Return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted)); }
public void ComputeSignature(System.Security.Cryptography.KeyedHashAlgorithm macAlg) { }
public bool CheckSignature(System.Security.Cryptography.KeyedHashAlgorithm macAlg) { throw null; }
/// <summary> /// 加密密码 /// </summary> /// <param name="pass">密码</param> /// <param name="passwordFormat">加密方式</param> /// <param name="salt">加密字符串</param> /// <returns></returns> private string EncodePassword(string pass, System.Web.Security.MembershipPasswordFormat passwordFormat, string salt) { if (passwordFormat == System.Web.Security.MembershipPasswordFormat.Clear) { return(pass); } byte[] bIn = System.Text.Encoding.Unicode.GetBytes(pass); byte[] bSalt = Convert.FromBase64String(salt); byte[] bRet = null; if (passwordFormat == System.Web.Security.MembershipPasswordFormat.Hashed) { System.Security.Cryptography.HashAlgorithm hashAlgorithm = this.GetHashAlgorithm(); if (hashAlgorithm is System.Security.Cryptography.KeyedHashAlgorithm) { System.Security.Cryptography.KeyedHashAlgorithm keyedHashAlgorithm = (System.Security.Cryptography.KeyedHashAlgorithm)hashAlgorithm; if (keyedHashAlgorithm.Key.Length == bSalt.Length) { keyedHashAlgorithm.Key = bSalt; } else { if (keyedHashAlgorithm.Key.Length < bSalt.Length) { byte[] bKey = new byte[keyedHashAlgorithm.Key.Length]; Buffer.BlockCopy(bSalt, 0, bKey, 0, bKey.Length); keyedHashAlgorithm.Key = bKey; } else { byte[] bKey = new byte[keyedHashAlgorithm.Key.Length]; int num; for (int i = 0; i < bKey.Length; i += num) { num = Math.Min(bSalt.Length, bKey.Length - i); Buffer.BlockCopy(bSalt, 0, bKey, i, num); } keyedHashAlgorithm.Key = bKey; } } bRet = keyedHashAlgorithm.ComputeHash(bIn); } else { byte[] bAll = new byte[bSalt.Length + bIn.Length]; Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length); Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length); bRet = hashAlgorithm.ComputeHash(bAll); } } else //System.Web.Security.MembershipPasswordFormat.Encrypted { byte[] bAll = new byte[bSalt.Length + bIn.Length]; Buffer.BlockCopy(bSalt, 0, bAll, 0, bSalt.Length); Buffer.BlockCopy(bIn, 0, bAll, bSalt.Length, bIn.Length); bRet = this.EncryptPassword(bAll); } return(Convert.ToBase64String(bRet)); }
public HMACSHA512Wrapper(System.Security.Cryptography.KeyedHashAlgorithm hmac) { _hmac = hmac; _hashName = nameof(HMACSHA512Wrapper); }