Skip to content

Instantly share code, notes, and snippets.

@marksteve
Created April 11, 2018 02:56
Show Gist options
  • Save marksteve/147352e1630d5174ca9db355704eeda9 to your computer and use it in GitHub Desktop.
Save marksteve/147352e1630d5174ca9db355704eeda9 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content=width=device-width>
<title>password</title>
<style>*{margin:0;padding:0}body,input{font:14px/1 Arial,Helvetica,sans-serif}body{padding:5em 1em;text-align:center;}input{padding:0.2em;margin:0.2em;}#d{font-size:4em}</style>
<p><input id=a type=password placeholder="master password"></p>
<p><input id=b placeholder=indentifier size=18><input id=c size=1 value=8></p>
<p id=d>password</p>
<script>
var $=function(x){return document.getElementById(x)}
$('b').onchange=$('c').onchange=function(){
var a=0,c='',d,rgb=[];
($('b').value+$('a').value).split('').forEach(function(b){a+=b.charCodeAt()})
a=parseInt(Math.abs(Math.sin(a)*Math.pow(10,parseInt($('c').value))))
d=String(a);d.split('').forEach(function(b,i){if(parseInt(i%(d.length/3))===0)rgb.push(parseInt(d.substr(i,3))%255)})
document.body.style.backgroundColor='rgb('+rgb[0]+','+rgb[1]+','+rgb[2]+')'
if(0.21*rgb[0]+0.72*rgb[1]+0.07*rgb[2]<255/3)document.body.style.color='rgb(255,255,255)'
else document.body.style.color='rgb(0,0,0)'
while(a>2){c+=String.fromCharCode(33+a%93);a/=10}
document.getElementById('d').innerText=c;}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment