public final class Garbler
extends java.lang.Object
garble(String, long[])
and degarble(String, long[])
methods,
which avoid allocating multiple temporary char arrays when multiple keys are used. A more major step of obfuscation
would be to run any garbling on already-compressed text, which LZSPlus
does by using this class.
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
degarble(java.lang.String garbled)
Given a garbled String that was produced by
garble(String) (using the default key), this reverses the
garbling and gets the original String. |
static java.lang.String |
degarble(java.lang.String garbled,
long key)
Given a garbled String that was produced by
garble(String, long) (using the given key), this reverses
the garbling and gets the original String. |
static java.lang.String |
degarble(java.lang.String garbled,
long[] keys)
Given a garbled String that was produced by
garble(String, long[]) (using the given keys), this
reverses the garbling and gets the original String. |
static java.lang.String |
degarble(java.lang.String garbled,
java.lang.String keyText)
Given a garbled String that was produced by
garble(String, String) (using the given keyText), this
reverses the garbling and gets the original String. |
static java.lang.String |
garble(java.lang.String text)
Garbles text with the default key.
|
static java.lang.String |
garble(java.lang.String text,
long key)
Garbles text with the given key as a long.
|
static java.lang.String |
garble(java.lang.String text,
long[] keys)
Garbles text with the given keys as a long array, effectively garbling the same text one time per item in keys.
|
static java.lang.String |
garble(java.lang.String text,
java.lang.String keyText)
Garbles text with the given keyText.
|
static long[] |
makeKeyArray(int size,
java.lang.String keyText)
If you need to produce an long array as a key for
garble(String, long[]) when you only have a String,
you can use this method if the String isn't too small (at least 8 char Strings should be fine). |
public static java.lang.String garble(java.lang.String text)
degarble(String)
, which also uses the
default key.text
- the text to garblepublic static java.lang.String garble(java.lang.String text, java.lang.String keyText)
degarble(String, String)
, which must be
given the same keyText.text
- the text to garblekeyText
- used to determine the key this will use to garble textpublic static java.lang.String garble(java.lang.String text, long key)
degarble(String, long)
, which must
be given the same key.text
- the text to garblekey
- the key this will use to garble textpublic static java.lang.String degarble(java.lang.String garbled)
garble(String)
(using the default key), this reverses the
garbling and gets the original String.garbled
- a String produced by a garble() method using the default keypublic static java.lang.String degarble(java.lang.String garbled, java.lang.String keyText)
garble(String, String)
(using the given keyText), this
reverses the garbling and gets the original String.garbled
- a String produced by a garble() method using the same keyTextkeyText
- the keyText that was used during garblingpublic static java.lang.String degarble(java.lang.String garbled, long key)
garble(String, long)
(using the given key), this reverses
the garbling and gets the original String.garbled
- a String produced by a garble() method using the same keyTextkey
- the key that was used during garblingpublic static java.lang.String garble(java.lang.String text, long[] keys)
degarble(String, long[])
, which must be given the same keys. This
method is more efficient than calling garble() repeatedly because it only allocates one temporary char array
for the whole batch of keys, as opposed to needing one temporary array per key with repeated calls.text
- the text to garblekeys
- the key array this will use to garble text, as a long arraypublic static java.lang.String degarble(java.lang.String garbled, long[] keys)
garble(String, long[])
(using the given keys), this
reverses the garbling and gets the original String. This is not the same as calling degarble() repeatedly, in
part because this uses the keys in reverse order (just like every part of the degarbling process, it needs to be
in reverse), and in part because this only creates one temporary char array for the whole batch of keys, instead
of creating one new char array per repeated call.garbled
- a String produced by a garble() method using the same keyTextkeys
- the key array that was used during garblingpublic static long[] makeKeyArray(int size, java.lang.String keyText)
garble(String, long[])
when you only have a String,
you can use this method if the String isn't too small (at least 8 char Strings should be fine). This produces a
diverse array of longs without the correlation between items that you would get if you just generated a sequence
of random longs from one small seed, by using multiple different CrossHash.Mist
objects to hash the text.size
- the size of the key array to produce; larger key arrays take proportionately longer to processkeyText
- the String to use as a basis for generating random-seeming numbers for keysgarble(String, long[])
and degarble(String, long[])
Copyright © Eben Howard 2012–2022. All rights reserved.