Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SHA Tester 2.0
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Text; using System.Security.Cryptography; using System.Globalization; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Client sends: " + Sha256StringHash("marcor")); Console.WriteLine("Server stores: " + Sha256StringHash(Sha256StringHash("marcor"), GetSalt(Guid.Parse("9585ac17-4b86-4b1e-963c-4100c736b432"), DateTime.Parse("2017-01-11 17:35:20")))); } public static string Sha256StringHash(string input) { using (var shaM = new SHA256Managed()) { var hash = shaM.ComputeHash(Encoding.UTF8.GetBytes(input)); return HashToString(hash); } } public static string Sha256StringHash(string input, string salt) { using (var shaM = new SHA256Managed()) { var bytesInput = Encoding.UTF8.GetBytes(input); var bytesSalt = Encoding.UTF8.GetBytes(salt); var data = new byte[bytesInput.Length + bytesSalt.Length]; bytesInput.CopyTo(data, 0); bytesSalt.CopyTo(data, bytesInput.Length); var hash = shaM.ComputeHash(Encoding.UTF8.GetBytes(input)); return HashToString(hash); } } public static string GetSalt(Guid id, DateTime createdAt) { var toHash = createdAt.Day % 2 == 0 ? id.ToString() + createdAt : createdAt.ToString(CultureInfo.InvariantCulture) + id; using (var shaM = new SHA256Managed()) { var hash = shaM.ComputeHash(Encoding.UTF8.GetBytes(toHash)); return HashToString(hash).Substring(0, 5); } } private static string HashToString(byte[] hash) { var sBuilder = new StringBuilder(); foreach (var b in hash) sBuilder.Append(b.ToString("x2")); return sBuilder.ToString(); } } }
run
|
edit
|
history
|
help
0
Timer1
Just tries to add/remove items to the list
RegEx
Print All Cards
lala
Boggle
Reverse String and Binary Search of floating point values
Better Random number blocks
Contravariance
Demonstration await Control returned to the Caller