WycliffeAssociates / jdenticon-kotlin

19 stars 8 forks source link

Use existing hash if valid, else generate one #6

Closed bseib closed 3 years ago

bseib commented 3 years ago

Require the hash argument to be a hexadecimal string of length 11 or greater.

Implement unit tests for the above.

fixes #5

bseib commented 3 years ago

I have updated this PR to behave the same as the javascript lib does. For the unit test I manually generated some test SVGs and manually confirmed that they visually match what the javascript lib generates. It is a small sample of six SVG files, but has cases for accepting an existing valid hash, or having to generate a new SHA hash.


For example, javascript generated with a valid 11+ character hash value:

https://jdenticon.com/#icon-deadbeef123

image

Matches our kotlin generated deadbeef123.svg:

image


Another example, where the string value must be hashed first

image

Matches our Alice.svg:

image

bseib commented 3 years ago

@jsarabia PR ready for review