java.lang.Object
net.i2p.imagegen.RandomArt
Draw an ASCII-Art representing the fingerprint so human brain can profit from its built-in pattern recognition ability. This technique is called "random art" and can be found in some scientific publications like this original paper. "Hash Visualization: a New Technique to improve Real-World Security", Perrig A. and Song D., 1999, International Workshop on Cryptographic Techniques and E-Commerce (CrypTEC '99) sparrow.ece.cmu.edu/~adrian/projects/validation/validation.pdf The subject came up in a talk by Dan Kaminsky, too. If you see the picture is different, the key is different. If the picture looks the same, you still know nothing. The algorithm used here is a worm crawling over a discrete plane, leaving a trace (augmenting the field) everywhere it goes. Movement is taken from dgst_raw 2bit-wise. Bumping into walls makes the respective movement vector be ignored for this turn. Graphs are not unambiguous, because circles in graphs can be walked in either direction.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringCharacters of the ASCII symbol field.private static final charASCII box border, bottom left.private static final charASCII box border, bottom.private static final charASCII box border, bottom right.private static final charASCII box border, left.private static final charASCII box border, right.private static final charASCII box border, top left.private static final charASCII box border, top.private static final charASCII box border, top right.private static final intBase of the symbol field values.private static final intWidth of the symbol field.private static final intHeight of the symbol field.private static final StringCharacters of the Unicode symbol field.private static final charUnicode box border, bottom left.private static final charUnicode box border, bottom.private static final charUnicode box border, bottom right.private static final charUnicode box border, left.private static final charUnicode box border, right.private static final charUnicode box border, top left.private static final charUnicode box border, top.private static final charUnicode box border, top right.Constructor Summary
ConstructorsConstructorDescriptionThe field geometry, the glyph strings and the render() entry points are all static, so an instance carries no state of its own.Method Summary
Modifier and TypeMethodDescriptionprivate static StringgetColor(long base, int mod) Chooses the color for a value.static Stringgnutls_key_fingerprint_randomart(byte[] dgst_raw, String key_type, int key_size, String prefix, boolean unicode, boolean html) Render a digest as the dr randomness "random art" block.static voidPrint a sample random art rendering, as an HTML page.
Field Details
FLDBASE
FLDSIZE_Y
FLDSIZE_X
A_augmentation_string
Characters of the ASCII symbol field.- See Also:
U_augmentation_string
Characters of the Unicode symbol field.- See Also:
A_BOX_TOP
A_BOX_BOTTOM
A_BOX_LEFT
A_BOX_RIGHT
A_BOX_TL
A_BOX_TR
A_BOX_BL
A_BOX_BR
U_BOX_TOP
U_BOX_BOTTOM
U_BOX_LEFT
U_BOX_RIGHT
U_BOX_TL
U_BOX_TR
U_BOX_BL
U_BOX_BR
Constructor Details
RandomArt
public RandomArt()The field geometry, the glyph strings and the render() entry points are all static, so an instance carries no state of its own.
Method Details
gnutls_key_fingerprint_randomart
public static String gnutls_key_fingerprint_randomart(byte[] dgst_raw, String key_type, int key_size, String prefix, boolean unicode, boolean html) Render a digest as the dr randomness "random art" block.- Parameters:
dgst_raw- the data to be visualized, recommend 64 bytes or lesskey_type- output in the first line, recommend 6 chars or lesskey_size- output in the first lineprefix- if non-null, prepend to every lineunicode- true to draw with Unicode box characters, not ASCII oneshtml- true to emit coloured div/pre HTML with a span per cell- Returns:
- the rendered random art, HTML when html is true, else plain text
getColor
Chooses the color for a value.- Parameters:
base- the value to colormod- the modulus applied first- Returns:
- the color name
main
Print a sample random art rendering, as an HTML page.- Parameters:
args- ignored; the sample digest is fixed in the body