Opened 3 years ago

Closed 3 years ago

#1652 closed enhancement (fixed)

Hash Visualizations

Reported by: zzz Owned by:
Priority: minor Milestone: 0.9.25
Component: apps/i2ptunnel Version: 0.9.21
Keywords: Cc:
Parent Tickets:

Subtickets

Change History (8)

comment:1 Changed 3 years ago by zzz

certtool -i from gnutls has an ascii art generator.

Found the source in lib/extras/randomart.c in gnutls source. It's liberally licensed. I'm going to hack-convert it to java and try it for 256-bit hashes and see how it looks. With some CSS and unicode chars we could make it pretty distinctive but keep it as chars rather than diving into jpeg-generators and the like.

comment:2 Changed 3 years ago by zzz

Translated to Java. switched the outer box to unicode chars as an experiment. Here's sample output for random data of length 16, 32, 48, 64 bytes. We could of course swap out the inner chars also.

┌──[ SHA  128]────┐
│         o.o.oo  │
│        o o S. ..│
│         o o  o +│
│          . .  =.│
│        ^  o  o .│
│       .  . .o   │
│      o +.    .  │
│       *.        │
│      ++         │
└─────────────────┘

┌──[XSHA  256]────┐
│.=               │
│+ *              │
│.*.              │
│+  +             │
│+ o o   ^        │
│.*.+ oS.         │
│=*X. .+          │
│B/ooo. .         │
│%=@Bo .          │
└─────────────────┘

┌──[XXSHA  384]───┐
│       .o.       │
│       ....      │
│    + o....      │
│+. = * o.o .     │
│o=B *.B.^ +      │
│+o*=.X+X   +     │
│=O.=++=.= . S o  │
│B.Bo= ...+o. =   │
│ =o+oo   o..     │
└─────────────────┘

┌──[XXXSHA  512]──┐
│.+oOO=o=o..      │
│  X+O==+ooo      │
│ +.X+=S+=o .     │
│. ==.==B+        │
│ o= + ..^*       │
│ o.*  .o*.+      │
│. +.*oo* +o      │
│ . +*O+.*o.      │
│ .=*XBo=o+       │
└─────────────────┘

comment:3 Changed 3 years ago by zzz

I just picked the 16 unicode symbols starting at U+2600 and got this;

┌──[ SHA  128]────┐
│     ☀   ☀ ☂☀★☄☂ │
│    ☀ ☀ ☁ ☂ ☀ ☃☀ │
│   ☀   ☁ ☀   ☀☀  │
│    ☀   ☀☁ ☀ ☁   │
│   ☀    ☎ ☀ ☁ ☀  │
│    ☀ ☀  ☁ ☀     │
│     ☀ ☀  ☀      │
│      ☏ ☀        │
│       ☀         │
└─────────────────┘

┌──[XSHA  256]────┐
│☀☀☂☂☃☁☁☀         │
│☁☂ ☂☁☃☀          │
│☂ ☂☂☁☁☁          │
│ ☏☀☁☂☂☀          │
│☀ ☀☀☁☄☃☀☎        │
│☁☂☁ ☂ ☃☄☀        │
│☂☂☀☂ ☁☀☀         │
│☂☀☀☀☂            │
│☂☁☁☂☀            │
└─────────────────┘

┌──[XXSHA  384]───┐
│           ☀☀★☆☄☆│
│          ☀ ☃☄☈☉☃│
│         ☀ ☀☃☃☂☏☁│
│        ☀☀☀☁☀ ☇☁☆│
│        ☎☀☁ ☂☁☁☉☉│
│         ☁ ☃☁☂☂☀☇│
│          ☂☁☁☁☁☀☁│
│         ☀☀☁☀☀ ☂ │
│        ☀☀☁☀    ☂│
└─────────────────┘

┌──[XXXSHA  512]──┐
│     ☂ ☀☀☀      ☀│
│  ☁ ☄ ☆ ☁☀      ☁│
│ ☁ ☄ ★ ☉☀☂  ☁ ☀☀☁│
│  ☁ ★ ☈☁★☂☄☁ ☂ ☁☁│
│   ☀ ☈☂☇☎☆☃☀☀ ☀ ☀│
│    ☂☂☏☄☃★☄☀     │
│    ☀☄☃☇☈☃☁☀☀    │
│    ☂☁☂★☃☄ ☀ ☀   │
│     ☁☂☂☁ ☂ ☀☀☀  │
└─────────────────┘

comment:4 Changed 3 years ago by str4d

I'm not convinced the above is particularly usable. IMHO there is "too much" going on in the randomart to the point that it is as overlook-able as the b32 it is trying to aid. I think anything we add needs to be simple enough for users to comprehend. That said, it does need to encode enough information that the likelihood of collisions isn't too high.

For reference, the code I use to generate the identicons for Bote is here:

https://github.com/i2p/i2p.i2p-bote.android/tree/master/app/src/main/java/im/delight/android/identicons

Last edited 3 years ago by str4d (previous) (diff)

comment:5 Changed 3 years ago by zzz

Are you opposed to the idea in general, or just think the examples above aren't particularly inspiring? If the latter, what do you think of the original code in certtool? (run certtool -i < somecert)

I've also HTML-ized it to add various colors. Not sure if that makes it better or worse.

That you have "identicons" and QR codes in Android Bote is a recent revelation. Will look at it soon. Folks at CCC lobbied for QR codes too. Will evaluate code, output, library size, license, ...

android https://github.com/delight-im/Android-Identicons
11KB github zip, Apacke 2.0

non-android java https://github.com/PauloMigAlmeida/identicon
21 KB github zip, MIT

java android/non-android qr code https://github.com/zxing/zxing
133 MB github zip!!!! Apache 2.0

was hesitant about the size and complexity of real image-generating libs but let's take a look and see.

Last edited 3 years ago by zzz (previous) (diff)

comment:6 Changed 3 years ago by zzz

I stripped everything but QR generation out of zxing, built it, and got a 57 KB jar. Not too bad.

comment:7 Changed 3 years ago by zzz

jar/war sizes

zxing 57 KB
identicon 12 KB
random art 6 KB
servlet to generate them on-the-fly 10 KB

under 100 KB total
all working, more or less

comment:8 Changed 3 years ago by zzz

  • Milestone changed from eventually to 0.9.25
  • Resolution set to fixed
  • Status changed from new to closed

Propped in 0.9.24-1 70f3ffd388bd1b63d3eb8a38b29e0bb2786b95f1
Still some minor cleanup to do but pretty much done.

Note: See TracTickets for help on using tickets.