-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEs1.cs
25 lines (23 loc) · 819 Bytes
/
Es1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System;
namespace Cryptopals
{
class Es1
{
public static void Exectute()
{
string input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
Console.WriteLine(String.Format("Hex input: {0}", input));
byte[] bytes = StringToByteArray(input);
string b64 = Convert.ToBase64String(bytes);
Console.WriteLine(String.Format("Base64 output: {0}", b64));
Console.WriteLine();
}
public static byte[] StringToByteArray(String hex)
{
byte[] bytes = new byte[hex.Length / 2];
for (int i = 0; i < hex.Length; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
return bytes;
}
}
}