build/authorify.js
function(pad) {
      var rval = true;

      if(encrypt) {
        if(pad) {
          rval = pad(8, _input, !encrypt);
        } else {
          // add PKCS#7 padding to block (each pad byte is the
          // value of the number of pad bytes)
          var padding = (_input.length() === 8) ? 8 : (8 - _input.length());
          _input.fillWithByte(padding, padding);
        }
      }

      if(rval) {
        // do final update
        _finish = true;
        cipher.update();
      }

      if(!encrypt) {
        // check for error: input data not a multiple of block size
        rval = (_input.length() === 0);
        if(rval) {
          if(pad) {
            rval = pad(8, _output, !encrypt);
          } else {
            // ensure padding byte count is valid
            var len = _output.length();
            var count = _output.at(len - 1);

            if(count > len) {
              rval = false;
            } else {
              // trim off padding bytes
              _output.truncate(count);
            }
          }
        }
      }

      return rval;
    }
function(pad) {
      var rval = true;

      if(encrypt) {
        if(pad) {
          rval = pad(8, _input, !encrypt);
        } else {
          // add PKCS#7 padding to block (each pad byte is the
          // value of the number of pad bytes)
          var padding = (_input.length() === 8) ? 8 : (8 - _input.length());
          _input.fillWithByte(padding, padding);
        }
      }

      if(rval) {
        // do final update
        _finish = true;
        cipher.update();
      }

      if(!encrypt) {
        // check for error: input data not a multiple of block size
        rval = (_input.length() === 0);
        if(rval) {
          if(pad) {
            rval = pad(8, _output, !encrypt);
          } else {
            // ensure padding byte count is valid
            var len = _output.length();
            var count = _output.at(len - 1);

            if(count > len) {
              rval = false;
            } else {
              // trim off padding bytes
              _output.truncate(count);
            }
          }
        }
      }

      return rval;
    }
function ( pad ) { var rval = true ; if ( encrypt ) { if ( pad ) { rval = pad ( 8 , _input , ! encrypt ) ; } else { // add PKCS#7 padding to block (each pad byte is the // value of the number of pad bytes) var padding = ( _input . length ( ) === 8 ) ? 8 : ( 8 - _input . length ( ) ) ; _input . fillWithByte ( padding , padding ) ; } } if ( rval ) { // do final update _finish = true ; cipher . update ( ) ; } if ( ! encrypt ) { // check for error: input data not a multiple of block size rval = ( _input . length ( ) === 0 ) ; if ( rval ) { if ( pad ) { rval = pad ( 8 , _output , ! encrypt ) ; } else { // ensure padding byte count is valid var len = _output . length ( ) ; var count = _output . at ( len - 1 ) ; if ( count > len ) { rval = false ; } else { // trim off padding bytes _output . truncate ( count ) ; } } } } return rval ; }
Finishes encrypting or decrypting.

@param pad a padding function to use, null for PKCS#7 padding,
signature(blockSize, buffer, decrypt).

@return true if successful, false on error.
Finishes encrypting or decrypting .