code: function scramble(password, salt)
  {
      var stage1 = sha1(password);
      var stage2 = sha1(stage1);
      var stage3 = sha1(salt + stage2);
      return xor(stage3, stage1);
  }
docs: mysql 4.2+ authorisation protocol token = sha1(salt + sha1(sha1(password))) xor sha1(password)