JavaScript
var dim = 8
var size = 350
var characters = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'-', '=', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+',
'[', ']', '\\', ';', '\'', ',', '.', '/', '{', '}', '|', ':', '"', '<', '>', '?', '`', '~'
]
function generatePasswordPath() {
var canvas = document.getElementById('path')
if (canvas.getContext) {
var ctx = canvas.getContext('2d')
ctx.fillStyle = '#fff'
ctx.fillRect(0,0,size,size)
ctx.strokeRect(0,0,size,size)
ctx.fillStyle = '#000'
ctx.font = '42px monospace'
var len = characters.length
var cellSize = size / dim
for(var x = 0; x < dim; x = x+1){
for(var y = 0; y < dim;y = y+1){
var i = Math.round((len - 1) * Math.random())
var c = characters[i]
ctx.fillStyle = '#000'
ctx.font = '42px monospace'
ctx.fillText(''+c, 8+x*cellSize, 32+y*cellSize)
}
}
}
}
var newButton = document.getElementById('new')
if (typeof newButton.addEventListener != 'undefined') {
newButton.addEventListener('click', generatePasswordPath)
}
else {
newButton.attachEvent('onclick', generatePasswordPath)
}
generatePasswordPath()