Skip to content

Instantly share code, notes, and snippets.

@taneltm
Last active July 3, 2017 08:19
Show Gist options
  • Save taneltm/d410d06640b55ecb90b1c32cc36300d7 to your computer and use it in GitHub Desktop.
Save taneltm/d410d06640b55ecb90b1c32cc36300d7 to your computer and use it in GitHub Desktop.
Password card
input(type="password" placeholder="Master password")
table
timer = null
$('input').on('input', ->
render $(this).val()
clearTimeout(timer)
timer = setTimeout(clearMasterPass, 30000)
)
clearMasterPass = ->
$('input').val('')
$('table').empty()
render = (master) ->
$('table').empty()
if !master then return
shaObj = new jsSHA("SHA-512", "TEXT");
shaObj.update(master);
a = shaObj.getHash("HEX");
b = ""
for i in [0...a.length]
char = a.charAt(i)
if i % 2 then char = char.toUpperCase()
b += char
c = b.match(/.{1,10}/g)
for pass, i in c
if pass.length == 10
$('table').append("<tr><td>#{i}</td><td>#{pass}</td></tr>")
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/2.2.0/sha512.js"></script>
<script src="https://use.fontawesome.com/633a459ec2.js"></script>
body
font-family monospace
body, input
background-color black
color mix(blue, cyan)
input
border 1px solid orange
padding 2px
&:focus
outline none
border 1px solid mix(blue, cyan)
input, table
width 200px
box-sizing border-box
table:not(:empty), td
border 1px solid mix(blue, cyan)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment