src/crypto_browser.js
function(password, salt, iterations, keysize) {
      var bits, hmac, self;
      if (iterations == null) {
        iterations = 10000;
      }
      if (keysize == null) {
        keysize = 512;
      }
      self = this;
      hmac = (function() {
        function hmac(key) {
          this.key = sjcl.codec.bytes.fromBits(key);
        }

        hmac.prototype.encrypt = function(sjclArray) {
          var bits, byteArray, hex;
          byteArray = sjcl.codec.bytes.fromBits(sjclArray);
          hex = self.hmac(byteArray, this.key, keysize);
          bits = sjcl.codec.hex.toBits(hex);
          return bits;
        };

        return hmac;

      })();
      salt = sjcl.codec.hex.toBits(this.toHex(salt));
      bits = sjcl.misc.pbkdf2(password, salt, iterations, keysize, hmac);
      return sjcl.codec.hex.fromBits(bits);
    }
function(password, salt, iterations, keysize) {
      var bits, hmac, self;
      if (iterations == null) {
        iterations = 10000;
      }
      if (keysize == null) {
        keysize = 512;
      }
      self = this;
      hmac = (function() {
        function hmac(key) {
          this.key = sjcl.codec.bytes.fromBits(key);
        }

        hmac.prototype.encrypt = function(sjclArray) {
          var bits, byteArray, hex;
          byteArray = sjcl.codec.bytes.fromBits(sjclArray);
          hex = self.hmac(byteArray, this.key, keysize);
          bits = sjcl.codec.hex.toBits(hex);
          return bits;
        };

        return hmac;

      })();
      salt = sjcl.codec.hex.toBits(this.toHex(salt));
      bits = sjcl.misc.pbkdf2(password, salt, iterations, keysize, hmac);
      return sjcl.codec.hex.fromBits(bits);
    }
function ( password , salt , iterations , keysize ) { var bits , hmac , self ; if ( iterations == null ) { iterations = 10000 ; } if ( keysize == null ) { keysize = 512 ; } self = this ; hmac = ( function ( ) { function hmac ( key ) { this . key = sjcl . codec . bytes . fromBits ( key ) ; } hmac . prototype . encrypt = function ( sjclArray ) { var bits , byteArray , hex ; byteArray = sjcl . codec . bytes . fromBits ( sjclArray ) ; hex = self . hmac ( byteArray , this . key , keysize ) ; bits = sjcl . codec . hex . toBits ( hex ) ; return bits ; } ; return hmac ; } ) ( ) ; salt = sjcl . codec . hex . toBits ( this . toHex ( salt ) ) ; bits = sjcl . misc . pbkdf2 ( password , salt , iterations , keysize , hmac ) ; return sjcl . codec . hex . fromBits ( bits ) ; }
Generate keys from password using PKDF2-HMAC-SHA512.
@param {String} password The password.
@param {String|Buffer} salt The salt.
@param {Number} [iterations=10000] The numbers of iterations.
@param {Numbers} [keysize=512] The length of the derived key in bits.
@return {String} Returns the derived key encoded as hex.
Generate keys from password using PKDF2 - HMAC - SHA512 .