public void HexToBase64_Test() { //https://cryptopals.com/sets/1/challenges/1 string hexstring = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"; string Base64 = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"; string Result = MyConvert.HexToBase64(hexstring); Assert.IsTrue(Base64 == Result); }
public void DetectAES_ECB_Test() //ECB = Electronic Codebook { //https://cryptopals.com/sets/1/challenges/8 string str = Util.GetFile(8); var Chunks = Util.Split(str, 32); var Duplicates = Chunks.GroupBy(x => x).Where(g => g.Count() > 1).Select(s => s.Key).ToList(); var bytes = MyConvert.HexToByteArray(Duplicates.First()); var Hex = MyConvert.BytesToHex(bytes); var B64 = MyConvert.HexToBase64(Hex); Assert.IsTrue("CGSa9w3Ab0/V0tacdEzSg" == B64); }