The Best Text Encryptor
Introduction(介紹)
Text Encryptor can encrypt all kind of language.文字加密器可以加密任何語言
Principle(原理)
Encryption(加密)
- The text will be converted with the charset you select to Base64
//java-Android
String result ;
byte[] base64_byte;
try {
encodeValue = Base64.encode(message.getBytes(charset), Base64.DEFAULT);
result = new String(base64_byte);
//result is the output
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
- Now,All of the text are converted to English characters.
- We use ASCII Code to convert characters to Integer.
- encrypt our data by XOR.
| A | B | F |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
//java-Android
StringBuilder result = new StringBuilder();
//message is the output of Base64
//key
char[] out = message.toCharArray();
int c;
for (char anOut : out) {
try {
c = (int) anOut;
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
}
c ^= key;//encrypt the character
String Hex = Integer.toHexString(c);
result.append(Hex).append(" ");
}
//result is the output
- Get the result as Hex
Decryption(解密)
- Decrypt the text of encryption with correct key.
//java-Android
//key
//message is the output of encryption
StringBuilder result = new StringBuilder();
String[] ASCII = message.split("\\s+");
for (String integer : ASCII) {
int b=0;
try {
b = Integer.parseInt(integer, 16);
// Convert Hex to Decimal
} catch (NumberFormatException e) {
e.printStackTrace();
}
char c = (char) (b ^ key);
result.append(c);
}
//result is the output
- Now,we get the Base64 characters,convert the characters with charset you select to text.
//java-Android
//message is the output of Base64
String result;
byte[] base64_byte = Base64.decode(message, Base64.DEFAULT);
try {
result= new String(base64_byte, charset);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//result is the output
Comments
Post a Comment