![]() |
Rabbit Escape
2017-01-14_18:33:47_+0000__(tag:_v0.10.1)
|
Static Public Member Functions | |
static String | encode (String input) |
static String | decode (String input) |
Private Member Functions | |
MegaCoder () | |
Static Private Member Functions | |
static char[] | getSortedUniqueChars (char[] charArray) |
static char[] | replaceUsingCharacterList (char[] charsListKey, char[] input) |
static char[] | exchangeCharacters (char[] chars, char a, char b) |
static char[] | shuffle (char[] input, int key) |
static char[] | copyArray (char[] input) |
Static Private Attributes | |
static final char[] | COMMON_CHARACTERS |
Obfuscate strings like a champion.
Swaps characters within the string around, swaps well-known characters with each other, and transposes the string by exchanging characters with other characters.
The MegaCoder is licensed here for use as part of rabbit-escape, but is also declared public domain, so that it may be used, without attribution, by anyone who needs obfuscation slightly more powerful than rot13, but less portable than base64. (For clarity, the MegaCoder is this single file).
The MegaCoder shuffle algorithm:
Input: An array of length l, A integer key k i = 0 while at least two array entries remain unswapped: if array entry i has not been swapped: j = (floor(length / 2) + 3i + k) mod l while array entry j has already been swapped: j = (j + 1) mod l swap entries i and j in the array i = i + 1 Output: The modified array
The MegaCoder replace algorithm:
Input: An key array k of length l, An array of characters x for i in [0, floor(l / 2)]: a = entry i in k; b = entry (l - 1 - i) in k replace all instances of a with b, and b with a, in the array x Output: The modified array x
The MegaCoder uniquify algorithm:
Input: An array of characters x Output: The set of characters in x sorted by value
The MegaCoder encode algorithm:
Input: An array of characters x of length l k1 = uniquify(x) x = replace(k1, x) k2 = shuffle(C, l) where C is the array of ASCII characters from space (0x20) to tilde (0x7e) x = replace(k2, x) x = shuffle(x, 0) Output: The modified array x
The MegaCoder decode algorithm:
Input: An array of characters x of length l x = shuffle(x, 0) k2 = shuffle(C, l) where C is the array of ASCII characters from space (0x20) to tilde (0x7e) x = replace(k2, x) k1 = uniquify(x) x = replace(k1, x) Output: The modified array x
|
private |
Private constructor for util class.
|
staticprivate |
|
static |
Decode a string using the MegaCoder obfuscation routine.
input | The ciphertext to decode. |
|
static |
Encode a string using the MegaCoder obfuscation routine.
input | The plaintext to encode. |
|
staticprivate |
Swap two characters with each other in a given characters list.
chars | The list of characters to search through. |
a | A character. |
b | Another character. |
|
staticprivate |
Create a new character array containing every character that appears in a given array once. The new array will be sorted by natural order.
charArray | The character array to process. |
|
staticprivate |
Replace characters in a string using a key.
charsListKey | A list of distinct characters. The first will be swapped with the last, and so on. If there is an odd number of characters then the middle character will not be swapped at all. |
input | The string to replace the characters in. |
|
staticprivate |
Shuffle the characters in the given string.
input | The string to be shuffled. |
key | A value that changes the shuffling algorithm. |
|
staticprivate |
A list of common ASCII characters that can be swapped with each other.