本文整理汇总了C#中AssemblyHashAlgorithm类的典型用法代码示例。如果您正苦于以下问题:C# AssemblyHashAlgorithm类的具体用法?C# AssemblyHashAlgorithm怎么用?C# AssemblyHashAlgorithm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssemblyHashAlgorithm类属于命名空间,在下文中一共展示了AssemblyHashAlgorithm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AssemblyHash
/// <summary>
/// Constructor
/// </summary>
/// <remarks>If <paramref name="hashAlgo"/> is an unsupported hash algorithm, then
/// <see cref="AssemblyHashAlgorithm.SHA1"/> will be used as the hash algorithm.</remarks>
/// <param name="hashAlgo">The algorithm to use</param>
public AssemblyHash(AssemblyHashAlgorithm hashAlgo) {
switch (hashAlgo) {
case AssemblyHashAlgorithm.MD5:
hasher = MD5.Create();
break;
case AssemblyHashAlgorithm.None:
case AssemblyHashAlgorithm.MD2:
case AssemblyHashAlgorithm.MD4:
case AssemblyHashAlgorithm.SHA1:
case AssemblyHashAlgorithm.MAC:
case AssemblyHashAlgorithm.SSL3_SHAMD5:
case AssemblyHashAlgorithm.HMAC:
case AssemblyHashAlgorithm.TLS1PRF:
case AssemblyHashAlgorithm.HASH_REPLACE_OWF:
default:
hasher = SHA1.Create();
break;
case AssemblyHashAlgorithm.SHA_256:
hasher = SHA256.Create();
break;
case AssemblyHashAlgorithm.SHA_384:
hasher = SHA384.Create();
break;
case AssemblyHashAlgorithm.SHA_512:
hasher = SHA512.Create();
break;
}
}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:38,代码来源:AssemblyHash.cs
示例2: GetHash
internal ImmutableArray<byte> GetHash(AssemblyHashAlgorithm algorithmId)
{
using (HashAlgorithm algorithm = TryGetAlgorithm(algorithmId))
{
// ERR_CryptoHashFailed has already been reported:
if (algorithm == null)
{
return ImmutableArray.Create<byte>();
}
switch (algorithmId)
{
case AssemblyHashAlgorithm.None:
case AssemblyHashAlgorithm.Sha1:
return GetHash(ref _lazySHA1Hash, algorithm);
case AssemblyHashAlgorithm.Sha256:
return GetHash(ref _lazySHA256Hash, algorithm);
case AssemblyHashAlgorithm.Sha384:
return GetHash(ref _lazySHA384Hash, algorithm);
case AssemblyHashAlgorithm.Sha512:
return GetHash(ref _lazySHA512Hash, algorithm);
case AssemblyHashAlgorithm.MD5:
return GetHash(ref _lazyMD5Hash, algorithm);
default:
throw ExceptionUtilities.UnexpectedValue(algorithmId);
}
}
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:33,代码来源:CryptographicHashProvider.cs
示例3: AssemblyHash
public AssemblyHash (AssemblyHashAlgorithm algorithm, byte[] value)
{
_algorithm = algorithm;
if (value != null)
_value = (byte[]) value.Clone ();
else
_value = null;
}
开发者ID:jack-pappas,项目名称:mono,代码行数:8,代码来源:AssemblyHash.cs
示例4: Hash
/// <summary>
/// Hash data
/// </summary>
/// <remarks>If <paramref name="hashAlgo"/> is an unsupported hash algorithm, then
/// <see cref="AssemblyHashAlgorithm.SHA1"/> will be used as the hash algorithm.</remarks>
/// <param name="data">The data</param>
/// <param name="hashAlgo">The algorithm to use</param>
/// <returns>Hashed data or null if <paramref name="data"/> was <c>null</c></returns>
public static byte[] Hash(byte[] data, AssemblyHashAlgorithm hashAlgo) {
if (data == null)
return null;
using (var asmHash = new AssemblyHash(hashAlgo)) {
asmHash.Hash(data);
return asmHash.ComputeHash();
}
}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:17,代码来源:AssemblyHash.cs
示例5: Read
public void Read(ClrModuleReader reader)
{
this.HashAlgId = (AssemblyHashAlgorithm)reader.Binary.ReadUInt32();
this.Version = reader.ReadVersion();
this.Flags = (AssemblyFlags)reader.Binary.ReadUInt32();
this.PublicKey = reader.ReadBlob();
this.Name = reader.ReadString();
this.Culture = reader.ReadString();
}
开发者ID:BGCX261,项目名称:zoompe-git,代码行数:9,代码来源:AssemblyEntry.cs
示例6: AssemblyHash
public AssemblyHash(AssemblyHashAlgorithm algorithm, byte[] value) {
_Algorithm = algorithm;
_Value = null;
if (value != null) {
int length = value.Length;
_Value = new byte[length];
Array.Copy(value, _Value, length);
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:10,代码来源:AssemblyHash.cs
示例7: AssemblyNameReference
public AssemblyNameReference(string name, Version version)
{
if (name == null)
throw new ArgumentNullException("name");
this.name = name;
this.version = version;
this.hash_algorithm = AssemblyHashAlgorithm.None;
this.token = new MetadataToken(TokenType.AssemblyRef);
}
开发者ID:beatcracker,项目名称:GUILess-Reflexil,代码行数:10,代码来源:AssemblyNameReference.cs
示例8: Create
public static IncrementalHash Create(AssemblyHashAlgorithm hashAlgorithm)
{
if (PortableShim.IncrementalHash.TypeOpt != null)
{
return new Core(hashAlgorithm);
}
else
{
return new Desktop(hashAlgorithm);
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:11,代码来源:IncrementalHash.cs
示例9: AssemblyNameReference
public AssemblyNameReference(string name, string culture, Version version)
{
if (name == null)
throw new ArgumentNullException ("name");
if (culture == null)
throw new ArgumentNullException ("culture");
m_name = name;
m_culture = culture;
m_version = version;
m_hashAlgo = AssemblyHashAlgorithm.None;
}
开发者ID:NALSS,项目名称:Telegraph,代码行数:11,代码来源:AssemblyNameReference.cs
示例10: AssemblyHash
public AssemblyHash(byte[] value)
{
this._Algorithm = AssemblyHashAlgorithm.SHA1;
this._Value = null;
if (value != null)
{
int length = value.Length;
this._Value = new byte[length];
Array.Copy(value, this._Value, length);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:AssemblyHash.cs
示例11: AssemblyReference
public AssemblyReference(string name, AssemblyAttributes attributes, Version version, AssemblyHashAlgorithm hashAlgorithm, uint publicKey, string culture)
: base(new MetaDataRow(
(byte)version.Major, (byte)version.Minor, (byte)version.Build, (byte)version.Revision,
(uint)attributes,
publicKey,
0U,
0U,
(uint)hashAlgorithm))
{
this._name = name;
this._culture = culture;
}
开发者ID:Rex-Hays,项目名称:GNIDA2,代码行数:12,代码来源:AssemblyReference.cs
示例12: GetHashAlgorithmNameObj
/// <summary>
/// Returns the actual FX implementation of HashAlgorithmName for given hash algorithm id.
/// </summary>
private static object GetHashAlgorithmNameObj(AssemblyHashAlgorithm algorithmId)
{
switch (algorithmId)
{
case AssemblyHashAlgorithm.Sha1:
return PortableShim.HashAlgorithmName.SHA1;
default:
// More algorithms can be added as needed.
throw ExceptionUtilities.UnexpectedValue(algorithmId);
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:15,代码来源:IncrementalHash.cs
示例13: LoadData
private void LoadData(CLIFile pFile)
{
HashAlgId = (AssemblyHashAlgorithm)pFile.ReadUInt32();
MajorVersion = pFile.ReadUInt16();
MinorVersion = pFile.ReadUInt16();
BuildNumber = pFile.ReadUInt16();
RevisionNumber = pFile.ReadUInt16();
Flags = (AssemblyFlags)pFile.ReadUInt32();
PublicKey = pFile.ReadBlobHeap(pFile.ReadHeapIndex(HeapOffsetSizes.Blob32Bit));
Name = pFile.ReadStringHeap(pFile.ReadHeapIndex(HeapOffsetSizes.Strings32Bit));
Culture = pFile.ReadStringHeap(pFile.ReadHeapIndex(HeapOffsetSizes.Strings32Bit));
}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:12,代码来源:AssemblyData.cs
示例14: AssemblyHash
public AssemblyHash(AssemblyHashAlgorithm algorithmId, byte[] value)
{
hashAlg = algorithmId;
if(value != null)
{
hash = new byte [value.Length];
Array.Copy(value, hash, value.Length);
}
else
{
hash = null;
}
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:13,代码来源:AssemblyHash.cs
示例15: AssemblyRow
/// <summary>
/// Initializes a new instance of the <see cref="AssemblyRow"/> struct.
/// </summary>
/// <param name="hashAlgId">The hash alg id.</param>
/// <param name="majorVersion">The major version.</param>
/// <param name="minorVersion">The minor version.</param>
/// <param name="buildNumber">The build number.</param>
/// <param name="revision">The revision.</param>
/// <param name="flags">The flags.</param>
/// <param name="publicKey">The public key.</param>
/// <param name="name">The name.</param>
/// <param name="culture">The culture.</param>
public AssemblyRow(AssemblyHashAlgorithm hashAlgId,
ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revision,
AssemblyAttributes flags, HeapIndexToken publicKey, HeapIndexToken name, HeapIndexToken culture)
{
this.hashAlgId = hashAlgId;
this.majorVersion = majorVersion;
this.minorVersion = minorVersion;
this.buildNumber = buildNumber;
this.revisionNumber = revision;
this.flags = flags;
this.publicKey = publicKey;
this.name = name;
this.culture = culture;
}
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:26,代码来源:AssemblyRow.cs
示例16: AssemblyRow
/// <summary>
/// Initializes a new instance of the <see cref="AssemblyRow"/> struct.
/// </summary>
/// <param name="hashAlgId">The hash alg id.</param>
/// <param name="majorVersion">The major version.</param>
/// <param name="minorVersion">The minor version.</param>
/// <param name="buildNumber">The build number.</param>
/// <param name="revision">The revision.</param>
/// <param name="flags">The flags.</param>
/// <param name="publicKey">The public key.</param>
/// <param name="name">The name.</param>
/// <param name="culture">The culture.</param>
public AssemblyRow(AssemblyHashAlgorithm hashAlgId,
ushort majorVersion, ushort minorVersion, ushort buildNumber, ushort revision,
AssemblyAttributes flags, HeapIndexToken publicKey, HeapIndexToken name, HeapIndexToken culture)
{
HashAlgId = hashAlgId;
MajorVersion = majorVersion;
MinorVersion = minorVersion;
BuildNumber = buildNumber;
Revision = revision;
Flags = flags;
PublicKey = publicKey;
Name = name;
Culture = culture;
}
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:26,代码来源:AssemblyRow.cs
示例17: IsSupportedAlgorithm
internal static bool IsSupportedAlgorithm(AssemblyHashAlgorithm algorithmId)
{
switch (algorithmId)
{
case AssemblyHashAlgorithm.None:
case AssemblyHashAlgorithm.Sha1:
case AssemblyHashAlgorithm.Sha256:
case AssemblyHashAlgorithm.Sha384:
case AssemblyHashAlgorithm.Sha512:
case AssemblyHashAlgorithm.MD5:
return true;
default:
return false;
}
}
开发者ID:riversky,项目名称:roslyn,代码行数:16,代码来源:CryptographicHashProvider.cs
示例18: AssemblyBuilder
internal AssemblyBuilder(Universe universe, AssemblyName name, string dir, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions)
: base(universe)
{
this.name = name.Name;
SetVersionHelper(name.Version);
if (!string.IsNullOrEmpty(name.Culture))
{
this.culture = name.Culture;
}
this.flags = name.RawFlags;
this.hashAlgorithm = name.HashAlgorithm;
if (this.hashAlgorithm == AssemblyHashAlgorithm.None)
{
this.hashAlgorithm = AssemblyHashAlgorithm.SHA1;
}
this.keyPair = name.KeyPair;
if (this.keyPair != null)
{
this.publicKey = this.keyPair.PublicKey;
}
else
{
byte[] publicKey = name.GetPublicKey();
if (publicKey != null && publicKey.Length != 0)
{
this.publicKey = (byte[])publicKey.Clone();
}
}
this.dir = dir ?? ".";
this.requiredPermissions = requiredPermissions;
this.optionalPermissions = optionalPermissions;
this.refusedPermissions = refusedPermissions;
if (universe.HasMscorlib && !universe.Mscorlib.__IsMissing && universe.Mscorlib.ImageRuntimeVersion != null)
{
this.imageRuntimeVersion = universe.Mscorlib.ImageRuntimeVersion;
}
else
{
this.imageRuntimeVersion = typeof(object).Assembly.ImageRuntimeVersion;
}
}
开发者ID:robert-j,项目名称:mono-fork,代码行数:41,代码来源:AssemblyBuilder.cs
示例19: GetPublicKeyToken
public static byte[] GetPublicKeyToken(byte[] publicKey, AssemblyHashAlgorithm hashAlgo)
{
byte[] token = null;
if (publicKey != null && publicKey.Length > 0)
{
HashAlgorithm ha;
switch (hashAlgo)
{
case AssemblyHashAlgorithm.Reserved:
ha = MD5.Create(); break;
default:
ha = SHA1.Create(); break;
}
byte[] hash = ha.ComputeHash(publicKey);
// we need the last 8 bytes in reverse order
token = new byte[8];
Array.Copy(hash, (hash.Length - 8), token, 0, 8);
Array.Reverse(token, 0, 8);
}
return token;
}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:22,代码来源:TokenUtils.cs
示例20: TryGetAlgorithm
private static HashAlgorithm TryGetAlgorithm(AssemblyHashAlgorithm algorithmId)
{
switch (algorithmId)
{
case AssemblyHashAlgorithm.None:
case AssemblyHashAlgorithm.Sha1:
return new SHA1CryptoServiceProvider();
case AssemblyHashAlgorithm.Sha256:
return new SHA256CryptoServiceProvider();
case AssemblyHashAlgorithm.Sha384:
return new SHA384CryptoServiceProvider();
case AssemblyHashAlgorithm.Sha512:
return new SHA512CryptoServiceProvider();
case AssemblyHashAlgorithm.MD5:
return new MD5CryptoServiceProvider();
default:
return null;
}
}
开发者ID:riversky,项目名称:roslyn,代码行数:24,代码来源:CryptographicHashProvider.cs
注:本文中的AssemblyHashAlgorithm类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论