Created
March 12, 2014 03:55
-
-
Save lukestanley/9500585 to your computer and use it in GitHub Desktop.
Renders an identicon from a string. It's not very good at the moment. It builds upon Caligatio's jsSHA and donpark's identicon - both MIT/BSD, I beleive.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas title="identicon -2044886870" width="48" height="48"></canvas> | |
<script type="text/javascript" src="https://raw.github.com/donpark/identicon/master/identicon-canvas/identicon_canvas.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/Caligatio/jsSHA/master/src/sha1.js"></script> | |
<script>//override existing render func, to not check for prefix | |
function render_identicon_canvases(prefix) { | |
var canvases = document.getElementsByTagName("canvas"); | |
var n = canvases.length; | |
for (var i = 0; i < n; i++) { | |
var node = canvases[i]; | |
//if (node.title && node.title.indexOf(prefix) == 0) { | |
if (node.style.display == 'none') node.style.display = "inline"; | |
var code = node.title.substring(prefix.length) * 1; | |
var size = node.width; | |
render_identicon(node, prefix, size); | |
//} | |
} | |
} | |
hashObj = new jsSHA(prompt(), "TEXT"); | |
render_identicon_canvases(parseInt(parseInt(hashObj.getHash("SHA-1", "HEX"),16)/100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment