-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSub_Decryption.cs
More file actions
88 lines (74 loc) · 2.06 KB
/
Sub_Decryption.cs
File metadata and controls
88 lines (74 loc) · 2.06 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
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/**
* The Sub_Encryption class contains the reverse
* shifting algorithm for J256's encryption.
*
* @author Jae Allen Reyes Nuguid
* @version 1.0
* @since 01-09-2017
*/
namespace J256
{
class Sub_Decryption
{
int key = 0, key0 = 0;
char[] x;
//Function: Decryption
//Decrypts the text and returns a String.
public char[] Decryption(int key, char[] x)
{
this.x = x;
this.key = key;
for (int z = 0; z < key; z++)
{
jShifter(x);
}
return x;
}
//Function: jShifter
//Shifts the characters to its corresponding number of loop.
public void jShifter(char[] p)
{
for (int x = 0; x < p.Length; x++)
{
if (p[x] >= '0' && p[x] <= '9')
{
for (int y = 0; y < key0; y++)
{
p[x]--;
if (p[x] < '0') p[x] = '9';
}
key0++;
}
else if (p[x] >= 'A' && p[x] <= 'Z')
{
for (int y = 0; y < key0; y++)
{
p[x]--;
if (p[x] < 'A') p[x] = 'Z';
}
key0++;
}
else if (p[x] >= 'a' && p[x] <= 'z')
{
for (int y = 0; y < key0; y++)
{
p[x]--;
if (p[x] < 'a') p[x] = 'z';
}
key0++;
}
else if (p[x] == '\\')
{
p[x] = ' ';
key0++;
}
if (key0 > 9) key0 = 0;
}
}
}
}