-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathProgram.cs
More file actions
75 lines (69 loc) · 2.34 KB
/
Copy pathProgram.cs
File metadata and controls
75 lines (69 loc) · 2.34 KB
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
73
74
75
using System.Text;
using System;
using System.Collections.Generic;
using whatcripto.ciphers;
using whatcripto.utils;
namespace Whatcripto
{
class Program
{
private static List<CipherDetect> ciphers = new List<CipherDetect>();
private static Boolean ciphersWithoutKey(string args) => args.Contains("-k") || args.Contains("--key");
private static void load()
{
ciphers.Add(new Base64());
ciphers.Add(new Base32());
ciphers.Add(new BaconianCipher());
ciphers.Add(new BinaryCode());
ciphers.Add(new HackerizeXS());
ciphers.Add(new MorseCode());
ciphers.Add(new RailFenceCipher());
ciphers.Add(new CesarCipher());
}
private static void loadWithKey(string key)
{
ciphers.Add(new VigenereCipher(key));
ciphers.Add(new XorCipher(key));
}
private static void help(string @string)
{
if (@string.Contains("-h") || @string.Contains("--help"))
{
Console.WriteLine(HelpMe.maintainer());
System.Environment.Exit(1);
}
}
static void Main(string[] args)
{
string @string = String.Join(" ", args);
help(@string);
if (ciphersWithoutKey(@string))
{
string[] values = @string.Split(" ");
for (int i = 0; i < values.Length - 1; i++)
{
if (values[i].Equals("-k") || values[i].Equals("--key"))
{
loadWithKey(values[i + 1]);
List<string> list = new List<string>(values);
list.Remove(values[i]);
list.Remove(values[i + 1]);
@string = String.Join(" ", list.ToArray());
break;
}
}
}
else
{
load();
}
ciphers.ForEach(cipher =>
{
if (cipher.identify(@string))
{
Console.WriteLine($"{cipher.name()} => {cipher.cleanText(@string)}\n");
}
});
}
}
}