Skip to content
Browse files

Update README.md

  • Loading branch information...
1 parent 089ccd4 commit 1bfe48a423fae380c55d1240212474ac3211e61b Adriel Café committed Oct 11, 2012
Showing with 39 additions and 0 deletions.
  1. +39 −0 README.md
View
39 README.md
@@ -26,3 +26,42 @@ Console.WriteLine(string.Format("{0} > {1} > {2}", str, encrypted, decrypted));
```
### Getting the hash of a string or a file
+This also is very simple. Look:
+```csharp
+// From a string
+string str = "my password";
+Console.WriteLine("Original String: " + str);
+Console.WriteLine("MD5: " + CryptoUtil.GetHashFromString(str, Algorithm.MD5));
+Console.WriteLine("SHA1: " + CryptoUtil.GetHashFromString(str, Algorithm.SHA1));
+Console.WriteLine("SHA256: " + CryptoUtil.GetHashFromString(str, Algorithm.SHA256));
+Console.WriteLine("SHA384: " + CryptoUtil.GetHashFromString(str, Algorithm.SHA384));
+Console.WriteLine("SHA512: " + CryptoUtil.GetHashFromString(str, Algorithm.SHA512));
+
+// From a file
+string str2 = @"c:\my_file.txt";
+Console.WriteLine("MD5: " + CryptoUtil.GetHashFromFile(str2, Algorithm.MD5));
+Console.WriteLine("SHA1: " + CryptoUtil.GetHashFromFile(str2, Algorithm.SHA1));
+Console.WriteLine("SHA256: " + CryptoUtil.GetHashFromFile(str2, Algorithm.SHA256));
+Console.WriteLine("SHA384: " + CryptoUtil.GetHashFromFile(str2, Algorithm.SHA384));
+Console.WriteLine("SHA512: " + CryptoUtil.GetHashFromFile(str2, Algorithm.SHA512));
+
+/* Output:
+ > STRING
+ Original String: my password
+ MD5: 329670c3265b6ccd392e622733e9772f
+ SHA1: a2f8f7fa195a080a22a689041daa8f2044f9f336
+ SHA256: bb14292d91c6d0920a5536bb41f3a50f66351b7b9d94c804dfce8a96ca1051f2
+ SHA384: 5cb69a1f4be83cf7d4eca6d8a806cd56a97c27b756f15a6417edbe2d7eaa16117230d137407bdf322172b683847f9d0e
+ SHA512: e28bdbf8faa97dab2203fcc89e397a4bf8d4a5b370421e5481a55f317caee4f81be5a810bb1cffc4695c32198717b9a6e835895852ee3a8689d0963463f2db15
+
+ > FILE
+ MD5: 21b2c27fbe338d800826e5ad67db7d0e
+ SHA1: 1e7bd74bd8f834b42c892d893976e5be5493e029
+ SHA256: 9e189ad1eb128bfd032968943f323dcf788fd6641cdc7ebddb72a3fa49aceb0f
+ SHA384: 70a5d4cf1ad3af999180496f38e8190ea77b12da08992ce3f129989cc0a70d2661e28e819ac60bfb878b78fbaef4c7f1
+ SHA512: 1c6aef5f220ad1c61c96f42da883c7046a3520d86144c5eb513b02d19587aca47fdeb71fd898bdc5be3fde0cd1f02f05e3104795ad9a0a8f19e292408ccdd7c3
+*/
+```
+
+
+#### Simple like that!

0 comments on commit 1bfe48a

Please sign in to comment.
Something went wrong with that request. Please try again.