-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.txt
72 lines (66 loc) · 2.9 KB
/
Program.txt
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using InformationSecurity;
using System.Text;
class Program
{
static void Main(string[] args)
{
RSATest();
StreebogTest();
KuznechikTest();
}
static void StreebogTest()
{
Streebog sbg = new Streebog();
string tmp = "Hello World!";
byte[] message =
{
0x32,0x31,0x30,0x39,0x38,0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x30,0x39,0x38,0x37,
0x36,0x35,0x34,0x33,0x32,0x31,0x30,0x39,0x38,0x37,0x36,0x35,0x34,0x33,0x32,0x31,
0x30,0x39,0x38,0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x30,0x39,0x38,0x37,0x36,0x35,
0x34,0x33,0x32,0x31,0x30,0x39,0x38,0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x30
};
Console.WriteLine("Hashing 256-bit");
Console.WriteLine("Original msg: " + Convert.ToHexString(message));
Console.WriteLine("Hash: " + sbg.GetHash(message));
Console.WriteLine("Original msg: " + tmp);
Console.WriteLine("Hash: " + sbg.GetHash(tmp));
Console.WriteLine();
Console.WriteLine("Hashing 512-bit");
Console.WriteLine("Original msg: " + Convert.ToHexString(message));
Console.WriteLine("Hash: " + sbg.GetHash512(message));
Console.WriteLine("Original msg: " + tmp);
Console.WriteLine("Hash: " + sbg.GetHash512(tmp));
}
static void RSATest()
{
RSA rsa = new RSA();
string msg = "Hello world!";
Console.WriteLine("Original message: " + msg);
var cipher = rsa.Encrypt(msg);
var msgfromcipher = rsa.Decrypt(cipher);
Console.WriteLine("Deciphered message: " + msgfromcipher);
Console.WriteLine("Cipher: " + cipher);
if (msg != msgfromcipher)
{
Console.WriteLine("Messages aren't equal!");
rsa.DebugPrint();
}
}
static void KuznechikTest()
{
Kuznechik kzn = new Kuznechik();
byte[] msg =
Encoding.Default.GetBytes("Привет мир!");
//Convert.FromHexString("1122334455667700ffeeddccbbaa9988");
//Encoding.Default.GetBytes("Бу! Испугался? Не бойся, я друг, я тебя не обижу. Иди сюда, иди ко мне, сядь рядом со мной, посмотри мне в глаза. Ты видишь меня? Я тоже тебя вижу. Давай смотреть друг на друга до тех пор, пока наши глаза не устанут. Ты не хочешь? Почему? Что-то не так?");
Console.WriteLine("msg.len = " + msg.Length);
byte[] cip = kzn.Encrypt(msg);
Console.WriteLine("Original: " + Encoding.Default.GetString(msg));
Console.WriteLine("Cipher: " + Convert.ToHexString(cip));
Console.WriteLine("Decipher: " + Encoding.Default.GetString(kzn.Decrypt(cip)));
}
}