-
Notifications
You must be signed in to change notification settings - Fork 2
/
ShowMyCode.com.java
104 lines (91 loc) · 2.91 KB
/
ShowMyCode.com.java
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package com.drcom.util;
public class Encrypt
{
private Encrypt()
{
}
public static String Decipher(String from_text)
{
char word[] = from_text.toCharArray();
String to_text = "";
long key = NumericPassword(KEYWORD);
int str_len = from_text.length() - 1;
for(int i = 0; i < str_len; i++)
{
word[i] = from_text.charAt(i);
int ch = word[i];
if(ch >= MIN_ASC && ch <= MAX_ASC)
{
i++;
ch -= MIN_ASC;
double offset = (double)(NUM_ASC + 1) * ((double)((key * (long)i) % MYPRIMENUMBER) / (double)MYPRIMENUMBER);
ch = (ch - (int)offset) % NUM_ASC;
if(ch < 0)
ch += NUM_ASC;
ch += MIN_ASC;
i--;
to_text = (new StringBuilder(String.valueOf(to_text))).append((char)ch).toString();
}
}
return to_text;
}
public static String Cipher(String from_text)
{
char word[] = from_text.toCharArray();
String to_text = "";
long key = NumericPassword(KEYWORD);
int str_len = from_text.length() - 1;
for(int i = 0; i <= str_len; i++)
{
word[i] = from_text.charAt(i);
int ch = word[i];
if(ch >= MIN_ASC && ch <= MAX_ASC)
{
i++;
ch -= MIN_ASC;
double offset = (double)(NUM_ASC + 1) * ((double)((key * (long)i) % MYPRIMENUMBER) / (double)MYPRIMENUMBER);
ch = (ch + (int)offset) % NUM_ASC;
ch += MIN_ASC;
i--;
to_text = (new StringBuilder(String.valueOf(to_text))).append((char)ch).toString();
}
}
return (new StringBuilder(String.valueOf(to_text))).append("a").toString();
}
public static long NumericPassword(String password)
{
long shift1 = 0L;
long shift2 = 0L;
long value = 0L;
int str_len = password.length();
for(int i = 0; i < str_len; i++)
{
long ch = password.charAt(i);
value ^= ch * MyIndex(shift1);
value ^= ch * MyIndex(shift2);
shift1 = (shift1 + 7L) % 19L;
shift2 = (shift2 + 13L) % 23L;
}
value = (value ^ MYPRIMENUMBER2) % MYPRIMENUMBER;
return value;
}
public static long MyIndex(long shadow)
{
long j = 1L;
for(long i = 1L; i <= shadow; i++)
j *= 2L;
return j;
}
private static int MIN_ASC;
private static int MAX_ASC;
private static int NUM_ASC;
private static long MYPRIMENUMBER = 0x188b9L;
private static long MYPRIMENUMBER2 = 0x18901L;
private static String KEYWORD = "TblRefreshCurMonthServiceUse";
static
{
MIN_ASC = 32;
MAX_ASC = 126;
NUM_ASC = (MAX_ASC - MIN_ASC) + 1;
}
}