- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
public String XOR_Encrypt(String source, String key)
{
byte plain_text[] = new byte[source.length()];
plain_text = source.getBytes();
byte key_mas[] = new byte[key.length()];
key_mas = key.getBytes();
int key_len = key.length();
int crypt_pos = 0;
for(int i = 0; i < source.length(); i++)
{
plain_text[i] = (byte)(plain_text[i] ^ 0xaa);
plain_text[i] = (byte)(plain_text[i] ^ key_mas[crypt_pos]);
if(crypt_pos >= key_len - 1)
crypt_pos = 0;
else
crypt_pos++;
}
String EText = ByteToHexString(plain_text);
return EText;
}
public static String EncodeSimmetr(String s)
{
int MultKey = 62142;
int AddKey = 11719;
byte f1[] = new byte[s.length()];
byte f[] = new byte[s.length()];
f = s.getBytes();
for(int i = 0; i < s.length(); i++)
{
f1[i] = (byte)(f[i] ^ MultKey);
MultKey ^= AddKey;
}
s = new String(f1);
return s;
}