Merge branch 'master' of github.com:alcexhim/MBS.Framework

This commit is contained in:
Michael Becker 2020-01-06 00:23:38 -05:00
commit 87162aa9cb
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
4 changed files with 35 additions and 2 deletions

View File

@ -7,7 +7,7 @@
<OutputType>Library</OutputType>
<RootNamespace>MBS.Framework.Console</RootNamespace>
<AssemblyName>MBS.Framework.CLI</AssemblyName>
<ReleaseVersion>1.0.*</ReleaseVersion>
<ReleaseVersion>4.0.2019.12</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View File

@ -11,6 +11,7 @@
<SchemaVersion>2.0</SchemaVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\MichaelBecker.snk</AssemblyOriginatorKeyFile>
<ReleaseVersion>4.0.2019.12</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -48,6 +49,7 @@
<Compile Include="Drawing\Vector.cs" />
<Compile Include="ArrayExtensions.cs" />
<Compile Include="Reflection.cs" />
<Compile Include="Security\Cryptography\ExtensionMethods.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -85,7 +85,11 @@ namespace MBS.Framework
catch (ReflectionTypeLoadException ex)
{
Console.Error.WriteLine("ReflectionTypeLoadException(" + ex.LoaderExceptions.Length.ToString() + "): " + asm.FullName);
Console.Error.WriteLine(ex.Message);
for (int i = 0; i < ex.LoaderExceptions.Length; i++)
{
Console.Error.WriteLine("\t" + ex.LoaderExceptions[i].Message);
Console.Error.WriteLine();
}
types1 = ex.Types;
}

View File

@ -0,0 +1,27 @@
using System.Security.Cryptography;
namespace MBS.Framework.Security.Cryptography
{
public static class ExtensionMethods
{
/// <summary>
/// Computes the hash of the specified value in the given encoding.
/// </summary>
/// <returns>The hash.</returns>
/// <param name="value">Value.</param>
public static string ComputeHash(this HashAlgorithm ha, string value, System.Text.Encoding encoding = null)
{
if (encoding == null) encoding = System.Text.Encoding.UTF8;
byte[] buffer = encoding.GetBytes(value);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
byte[] output = ha.ComputeHash(buffer);
for (int i = 0; i < output.Length; i++)
{
sb.Append(output[i].ToString("x").PadLeft(2, '0'));
}
return sb.ToString();
}
}
}