-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
executable file
·44 lines (35 loc) · 1.45 KB
/
Program.cs
File metadata and controls
executable file
·44 lines (35 loc) · 1.45 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
using System;
namespace codenation {
class Program {
const string token = "";
static char[] alphabet = ("abcdefghijklmnopqrstuvwxyz").ToCharArray ();
static void Main (string[] args) {
Import import = new Import (token);
Data data = import.GetData ();
Console.WriteLine (data);
char[] codedArray = data.cifrado.ToCharArray ();
char[] decodedArray = new char[codedArray.Length];
Console.WriteLine (data.cifrado);
for (int i = 0; i < codedArray.Length; i++) {
try {
int oldPos = Array.IndexOf (alphabet, codedArray[i]);
int newPos = GetNewPos (oldPos, data);
decodedArray[i] = alphabet[newPos];
} catch {
decodedArray[i] = codedArray[i];
}
}
foreach (var item in decodedArray)
data.decifrado += item;
Console.WriteLine (data.decifrado.ToString ());
data.resumo_criptografico = Hash.coder (data.decifrado);
Export.SubmitAnswer (data);
}
static int GetNewPos (int oldPos, Data data) {
int pos = oldPos - data.numero_casas;
if (pos < 0 && Math.Abs (pos) <= data.numero_casas)
pos = alphabet.Length + oldPos - data.numero_casas;
return pos;
}
}
}