Christos Tzamos

Email:
@mit.edu
tzamos mymail
Phone:
909-1739
(617)- myphone
Office: 32-G630, Stata Center
Web: christos.me
Google Scholar | DBLP | arXiv | Github
About | Research | Awards

Generate unique passwords using a master password

< Back to home

Inspired by the password generator of Chris Zarate, I created a bookmarklet that generates unique passwords for websites based on md5 hashing of a master password. It is a simplified version made specifically to not require external libraries like jquery or communication with a server. It uses md5 from js-crypto. Use with caution!

Login

Get it by dragging the link to your bookmarks bar. Below is the source code for convenience. It computes a hash using the following formula: "md5(domain#pass)a1A.". The md5 is truncated to 12 characters to give a 16 character password in total.

var d = location.protocol+'//'+location.hostname+(location.port?':'+location.port: '');
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var html = 
 "<style>\
    form{margin:0;}\
    input{display:block;padding:4px;margin:5px 0;width:100%;}\
    div{background:#fa0;height:20px;margin-top:5px;padding:2px;}\
    button{display:inline-block;color:white;height:20px;\
      background:brown;outline:none;border:none;width:30%;}\
  </style>\
  <form id='f'>\
    <input type='text' value='"+ document.domain+"'><input type='password' placeholder='pwd'>\
    <button type='submit'>login</button>\
    <button type='button' onclick='javascript:show()'>show</button>\
    <button type='button' onclick='javascript:done()'>close</button>\
    <div></div>\
  </form>\
  <sc"+"ript>\
    z=document;d= document.getElementsByTagName('div')[0];\
    md5=function(){for(var m=[],l=0;64>l;)m[l]=0|4294967296*Math.abs(Math.sin(++l));return function(c){var e,g,f,a,h=[];c=unescape(encodeURI(c));for(var b=c.length,k=[e=1732584193,g=-271733879,~e,~g],d=0;d<=b;)h[d>>2]|=(c.charCodeAt(d)||128)<<8*(d++%4);h[c=16*(b+8>>6)+14]=8*b;for(d=0;d<c;d+=16){b=k;for(a=0;64>a;)b=[f=b[3],(e=b[1]|0)+((f=b[0]+[e&(g=b[2])|~e&f,f&e|~f&g,e^g^f,g^(e|~f)][b=a>>4]+(m[a]+(h[[a,5*a+1,3*a+5,7*a][b]%16+d]|0)))<<(b=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*b+a++%4])|f>>>32-b),e,g];for(a=4;a;)k[--a]=k[a]+b[a]}for(c='';32>a;)c+=(k[a>>3]>>4*(1^a++&7)&15).toString(16);return c}}();\
    function compute() {\
      i= document.getElementsByTagName('input');\
      return md5(i[0].value+'#'+i[1].value).substr(0,12)+'a1A.';\
    }\
    function send(e){\
      if(e.preventDefault) e.preventDefault();\
      d.innerHTML='*****';\
      parent.postMessage(compute(),'"+d+"');\
      return false;\
    }\
    function done(){\
      parent.postMessage('x','"+d+"');\
    }\
    function show(){\
      d.innerHTML=compute();\
    }\
    form= document.getElementById('f');\
    form['"+eventMethod+"']('submit',send);\
  </"+"script>";
var iframe =  document.createElement('iframe');
iframe.src = 'data:text/html;charset=utf-8,' + encodeURI(html);
iframe.style = 'position:fixed;top:10px;right:10px;z-index:1234567890;background:gold;width:200px;height:130px;border:0;box-shadow: 0 0 10px black;';
 document.body.appendChild(iframe);
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
eventer(messageEvent,function(e) {
  var m = e.data;
  if(m=='x') { document.body.removeChild( iframe );return;}
  var inputs =  document.getElementsByTagName("input");
  for (var i=0; i<inputs.length; i++) {
    if (inputs[i].type.toLowerCase() === "password") {
      inputs[i].focus();
      inputs[i].value = m;
    }
  }
},false);