1

I've been given the task to implement Identicon using Delphi. I have searched the internet and still did not find anything. so where do I begin, is there someone here who can give an explanation?

tshepang
  • 12,111
  • 21
  • 91
  • 136

2 Answers2

21

This is just an explanation to give you the idea of the Identicons.

Identicons are graphical representations of a bunch of bytes most likely a hash value.

Lets take a sample MD5 hash value (16 bytes)

abf5787309f3c4d5b255237c0b67dd5e

Ok let them arrange in a different way

ab f5 78 73
09 f3 c4 d5
b2 55 23 7c
0b 67 dd 5e

Now we have 16 fields each representing a byte. So we could build an image with 256 different small images. But maybe we can break it down to a less complicated method.

Lets take one byte (the first one ab) and its binary representation

10101011

Ok, let them arrange in a different way :o)

10 10
10 11

Now we have 4 fields and each field can have one of four states. And that is very easy to manage 4 different images.

00 = empty
01 = /
10 = \
11 = X

Back to our byte we will get this

┌─────┐
│ \ \ │
│ \ X │
└─────┘

And back to the whole we get

┌─────┬─────┬─────┬─────┐
│ \ \ │ X X │ / X │ / X │
│ \ X │ / / │ \   │   X │
├─────┼─────┼─────┼─────┤
│     │   X │ X   │ X / │
│ \ / │ X   │ /   │ / / │
├─────┼─────┼─────┼─────┤
│ \ X │ / / │   \ │ / X │
│   \ │ / / │   X │ X   │
├─────┼─────┼─────┼─────┤
│     │ / \ │ X / │ / / │
│ \ X │ / X │ X / │ X \ │
└─────┴─────┴─────┴─────┘

The whole point here is reduction into easy to handle small parts.

TLama
  • 75,147
  • 17
  • 214
  • 392
Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
1

I once started to port the original library to Delphi / Graphics32. However, I never found the time to finish the small project until now. The source code together with a sample application can be found on my website (see Delphi -> Graphics32).

Originally it was meant to show some new vector graphic features from the upcoming version 2.0. Despite the fact, that this has still not been released, the source code can already be compiled with the code in the trunk repository.

CWBudde
  • 1,783
  • 1
  • 24
  • 28