Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Comparing hashing with different encoding and also transferring bytes
//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; namespace Rextester { public class Program { public static void Main(string[] args) { string key = "072e77e426f92738a72fe23c4d1953b4"; string text = "{super duper long string}"; System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); Byte[] keyBytes = encoding.GetBytes(key); Byte[] textBytes = encoding.GetBytes(text); System.Text.ASCIIEncoding encoding2 = new System.Text.ASCIIEncoding(); byte[] ascTextBytes = encoding2.GetBytes(key); byte[] textBytes2 = encoding2.GetBytes(text); Console.WriteLine("Strings"); Console.WriteLine(BitConverter.ToString(keyBytes)); Console.WriteLine(BitConverter.ToString(ascTextBytes)); Console.WriteLine("Hashes"); Byte[] hashBytes; Byte[] hashBytes2; using (HMACSHA1 hash = new HMACSHA1(keyBytes)) hashBytes = hash.ComputeHash(textBytes); Console.WriteLine(BitConverter.ToString(hashBytes)); using (HMACSHA1 hash2 = new HMACSHA1(ascTextBytes)) hashBytes2 = hash2.ComputeHash(textBytes2); Console.WriteLine(BitConverter.ToString(hashBytes2)); Console.WriteLine(Convert.ToBase64String(hashBytes)); Console.WriteLine(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(BitConverter.ToString(hashBytes)))); } } }
run
|
edit
|
history
|
help
1
Programmes
borrar_xml_tags_vacios
aa
IEnumerable visibility of bag
User
CodeAdvent
check ca a place
Reverse words in string
Main4
Binary search tree - Post-order Traversal