1+ using System ;
2+ using System . Linq ;
3+
4+ namespace KerfuffleCipher
5+ {
6+ public class Charset
7+ {
8+ public static char [ , ] smallAlphaChar = new char [ 2 , 13 ]
9+ {
10+ {
11+ 'a' ,
12+ 'b' ,
13+ 'c' ,
14+ 'd' ,
15+ 'e' ,
16+ 'f' ,
17+ 'g' ,
18+ 'h' ,
19+ 'i' ,
20+ 'j' ,
21+ 'k' ,
22+ 'l' ,
23+ 'm'
24+ } ,
25+ {
26+ 'n' ,
27+ 'o' ,
28+ 'p' ,
29+ 'q' ,
30+ 'r' ,
31+ 's' ,
32+ 't' ,
33+ 'u' ,
34+ 'v' ,
35+ 'w' ,
36+ 'x' ,
37+ 'y' ,
38+ 'z'
39+ }
40+ } ;
41+
42+ public static char [ , ] bigAlphaChar = new char [ 2 , 13 ]
43+ {
44+ {
45+ 'A' ,
46+ 'B' ,
47+ 'C' ,
48+ 'D' ,
49+ 'E' ,
50+ 'F' ,
51+ 'G' ,
52+ 'H' ,
53+ 'I' ,
54+ 'J' ,
55+ 'K' ,
56+ 'L' ,
57+ 'M'
58+ } ,
59+ {
60+ 'N' ,
61+ 'O' ,
62+ 'P' ,
63+ 'Q' ,
64+ 'R' ,
65+ 'S' ,
66+ 'T' ,
67+ 'U' ,
68+ 'V' ,
69+ 'W' ,
70+ 'X' ,
71+ 'Y' ,
72+ 'Z'
73+ }
74+ } ;
75+
76+ public static char [ ] specialSymbol = new char [ 33 ]
77+ {
78+ '!' ,
79+ '@' ,
80+ '#' ,
81+ '$' ,
82+ '%' ,
83+ '^' ,
84+ '&' ,
85+ '*' ,
86+ '(' ,
87+ ')' ,
88+ '-' ,
89+ '=' ,
90+ '[' ,
91+ ']' ,
92+ '\\ ' ,
93+ ';' ,
94+ '\' ' ,
95+ ',' ,
96+ '.' ,
97+ '/' ,
98+ '_' ,
99+ '+' ,
100+ '{' ,
101+ '}' ,
102+ '|' ,
103+ ':' ,
104+ '"' ,
105+ '<' ,
106+ '>' ,
107+ '?' ,
108+ ' ' ,
109+ '`' ,
110+ '~'
111+ } ;
112+
113+ public static char [ ] number = new char [ 10 ]
114+ {
115+ '1' ,
116+ '2' ,
117+ '3' ,
118+ '4' ,
119+ '5' ,
120+ '6' ,
121+ '7' ,
122+ '8' ,
123+ '9' ,
124+ '0'
125+ } ;
126+
127+ public static bool integrityCheck = false ;
128+
129+ public static char GetChar ( int x , int y , int z )
130+ {
131+ if ( z < 26 )
132+ return smallAlphaChar [ y - 1 , x - 1 ] ;
133+ if ( z < 51 )
134+ return bigAlphaChar [ y - 1 , x - 1 ] ;
135+ if ( z < 76 )
136+ return specialSymbol [ x - 1 ] ;
137+ if ( z < 101 )
138+ {
139+ if ( y != 2 )
140+ integrityCheck = true ;
141+ return number [ x - 1 ] ;
142+ }
143+ integrityCheck = true ;
144+ return 'a' ;
145+ }
146+
147+ public static int [ ] GetMatrix ( char ch )
148+ {
149+ int num1 = - 1 ;
150+ int randomZcoordinate ;
151+ int num2 ;
152+ if ( number . Contains ( ch ) )
153+ {
154+ randomZcoordinate = GenerateRandomZCoordinate ( 3 ) ;
155+ num2 = 2 ;
156+ for ( int index = 0 ; index < number . Length ; ++ index )
157+ {
158+ if ( number [ index ] . Equals ( ch ) )
159+ {
160+ num1 = index + 1 ;
161+ break ;
162+ }
163+ }
164+ }
165+ else
166+ {
167+ if ( ! specialSymbol . Contains ( ch ) )
168+ return Test ( ch ) ;
169+ randomZcoordinate = GenerateRandomZCoordinate ( 2 ) ;
170+ num2 = new Random ( ) . Next ( 0 , 4 ) ;
171+ for ( int index = 0 ; index < specialSymbol . Length ; ++ index )
172+ {
173+ if ( specialSymbol [ index ] . Equals ( ch ) )
174+ {
175+ num1 = index + 1 ;
176+ break ;
177+ }
178+ }
179+ }
180+ return new int [ 3 ] { num1 , num2 , randomZcoordinate } ;
181+ }
182+
183+ public static int GenerateRandomZCoordinate ( int type )
184+ {
185+ int num = 0 ;
186+ Random random = new Random ( Guid . NewGuid ( ) . GetHashCode ( ) ) ;
187+ switch ( type )
188+ {
189+ case 0 :
190+ num += random . Next ( 0 , 26 ) ;
191+ break ;
192+ case 1 :
193+ num += random . Next ( 25 , 51 ) ;
194+ break ;
195+ case 2 :
196+ num += random . Next ( 51 , 76 ) ;
197+ break ;
198+ case 3 :
199+ num += random . Next ( 76 , 101 ) ;
200+ break ;
201+ }
202+ return num ;
203+ }
204+
205+ public static int GenerateNumber ( int min , int max )
206+ {
207+ return new Random ( Guid . NewGuid ( ) . GetHashCode ( ) ) . Next ( min , max + 1 ) ;
208+ }
209+
210+ public static int [ ] GetLowerCase ( char ch )
211+ {
212+ int [ ] numArray = new int [ 3 ] ;
213+ bool flag = false ;
214+ for ( int index1 = 0 ; index1 < smallAlphaChar . Length / 13 ; ++ index1 )
215+ {
216+ for ( int index2 = 0 ; index2 < smallAlphaChar . Length / 2 ; ++ index2 )
217+ {
218+ if ( smallAlphaChar [ index1 , index2 ] . Equals ( ch ) )
219+ {
220+ numArray [ 0 ] = index2 + 1 ;
221+ numArray [ 1 ] = index1 + 1 ;
222+ numArray [ 2 ] = GenerateRandomZCoordinate ( 0 ) ;
223+ flag = true ;
224+ break ;
225+ }
226+ }
227+ if ( flag )
228+ break ;
229+ }
230+ return numArray ;
231+ }
232+
233+ public static int [ ] GetUpperCase ( char ch )
234+ {
235+ int [ ] numArray = new int [ 3 ] ;
236+ bool flag = false ;
237+ for ( int index1 = 0 ; index1 < bigAlphaChar . Length / 13 ; ++ index1 )
238+ {
239+ for ( int index2 = 0 ; index2 < bigAlphaChar . Length / 2 ; ++ index2 )
240+ {
241+ if ( bigAlphaChar [ index1 , index2 ] . Equals ( ch ) )
242+ {
243+ numArray [ 0 ] = index2 + 1 ;
244+ numArray [ 1 ] = index1 + 1 ;
245+ numArray [ 2 ] = GenerateRandomZCoordinate ( 1 ) ;
246+ flag = true ;
247+ break ;
248+ }
249+ }
250+ if ( flag )
251+ break ;
252+ }
253+ return numArray ;
254+ }
255+
256+ public static int [ ] Test ( char ch )
257+ {
258+ switch ( ch )
259+ {
260+ case 'A' :
261+ case 'B' :
262+ case 'C' :
263+ case 'D' :
264+ case 'E' :
265+ case 'F' :
266+ case 'G' :
267+ case 'H' :
268+ case 'I' :
269+ case 'J' :
270+ case 'K' :
271+ case 'L' :
272+ case 'M' :
273+ case 'N' :
274+ case 'O' :
275+ case 'P' :
276+ case 'Q' :
277+ case 'R' :
278+ case 'S' :
279+ case 'T' :
280+ case 'U' :
281+ case 'V' :
282+ case 'W' :
283+ case 'X' :
284+ case 'Y' :
285+ case 'Z' :
286+ return GetUpperCase ( ch ) ;
287+ case 'a' :
288+ case 'b' :
289+ case 'c' :
290+ case 'd' :
291+ case 'e' :
292+ case 'f' :
293+ case 'g' :
294+ case 'h' :
295+ case 'i' :
296+ case 'j' :
297+ case 'k' :
298+ case 'l' :
299+ case 'm' :
300+ case 'n' :
301+ case 'o' :
302+ case 'p' :
303+ case 'q' :
304+ case 'r' :
305+ case 's' :
306+ case 't' :
307+ case 'u' :
308+ case 'v' :
309+ case 'w' :
310+ case 'x' :
311+ case 'y' :
312+ case 'z' :
313+ return GetLowerCase ( ch ) ;
314+ default :
315+ return new int [ 3 ] { - 1 , - 1 , - 1 } ;
316+ }
317+ }
318+ }
319+ }
0 commit comments