From 1ef41b568e0ea75e4df2b980761b841ca8f5ebcd Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 30 Dec 2014 20:50:56 +0000 Subject: [PATCH] Added File for general global functions --- Pithos.csproj | 1 + tools.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tools.cs diff --git a/Pithos.csproj b/Pithos.csproj index a48f0c2..3074e21 100644 --- a/Pithos.csproj +++ b/Pithos.csproj @@ -51,6 +51,7 @@ mainWindow.cs + Form diff --git a/tools.cs b/tools.cs new file mode 100644 index 0000000..92f599c --- /dev/null +++ b/tools.cs @@ -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(); + } + } +}