Added File for general global functions

This commit is contained in:
Jake Howard 2014-12-30 20:50:56 +00:00
parent bb9001cbed
commit 1ef41b568e
2 changed files with 28 additions and 0 deletions

View file

@ -51,6 +51,7 @@
<DependentUpon>mainWindow.cs</DependentUpon> <DependentUpon>mainWindow.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="privateFunctions.cs" /> <Compile Include="privateFunctions.cs" />
<Compile Include="tools.cs" />
<Compile Include="unlock.cs"> <Compile Include="unlock.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

27
tools.cs Normal file
View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
namespace Pithos
{
class tools
{
public static string hash(string input)
{
// step 1, calculate MD5 hash from input
MD5 md5 = MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
// step 2, convert byte array to hex string
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("X2"));
}
return sb.ToString();
}
}
}