function coverPass(thePass,theName) {
  thePass += theName; // concat the password and name to get more unique

  var a = 0x67452301;
  var b = 0xEFCDAB89;
  var c = 0x98BADCFE;
  var d = 0x10325476;
  var e = 0xC3D2E1F0;
  var w = new Array(80);
  var nblk = ((thePass.length + 8) >> 6) + 1;
  var x = new Array(nblk * 16);
  var i = 0;
  var j = 0;
  
  for(i=0; i<(nblk * 16); i++) {
    x[i] = 0;
  }
  for(i=0; i<thePass.length; i++) {
    x[i >> 2] |= thePass.charCodeAt(i) << (24 - (i % 4) * 8);
  }
  x[i >> 2] |= 0x80 << (24 - (i % 4) * 8);
  x[nblk * 16 - 1] = thePass.length * 8;

  for(i = 0; i < x.length; i += 16) {
    oldA = a;
    oldB = b;
    oldC = c;
    oldD = d;
    oldE = e;

    for(j = 0; j < 80; j++) {
      if(j < 16) w[j] = x[i + j];
      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
      t = sum32(sum32(rol(a, 5), ft(j, b, c, d)), sum32(sum32(e, w[j]), kt(j)));
      e = d;
      d = c;
      c = rol(b, 30);
      b = a;
      a = t;
    }

    a = sum32(a, oldA);
    b = sum32(b, oldB);
    c = sum32(c, oldC);
    d = sum32(d, oldD);
    e = sum32(e, oldE);
  }
  return numToHex(a) + numToHex(b) + numToHex(c) + numToHex(d) + numToHex(e);
}

function numToHex(num) {  // convert to a hex string
  hexStr = "";
  for(var i=7; i>=0; i--) {
    hexStr += "0123456789abcdef".charAt((num >> (i * 4)) & 0x0F);
  }
  return hexStr;
}

function ft(t, b, c, d) {
  if(t < 20) return (b & c) | ((~b) & d);
  if(t < 40) return b ^ c ^ d;
  if(t < 60) return (b & c) | (b & d) | (c & d);
  return(b ^ c ^ d);
}

function kt(t) {
  if(t < 20) {
    return(0x5A827999);
  }
  if(t < 40) {
    return(0x6ED9EBA1);
  }
  if(t < 60) {
    return(0x8F1BBCDC);
  }
  return(0xCA62C1D6);
}

function sum32(x, y) {
  return ((x&0x7FFFFFFF) + (y&0x7FFFFFFF)) ^ (x&0x80000000) ^ (y&0x80000000);
}

function rol(theNum, cnt) {
  return (theNum << cnt) | (theNum >>> (32 - cnt));
}
