lib/signature.js
function( input, key ) {

    if( !Buffer.isBuffer( input ) )
      throw new TypeError( 'Input must be a buffer' )

    if( this.type === 'PLAIN' )
      return Buffer.allocUnsafe(0)

    if( !Buffer.isBuffer( key ) )
      throw new TypeError( 'Key must be a buffer' )

    var signature = this.type === 'HS' ?
      crypto.createHmac( this.algorithm + this.bits, key ) :
      crypto.createSign( this.algorithm + this.bits )

    signature.update( input )

    var digest = this.type === 'HS' ?
      signature.digest() :
      signature.sign( key )

    if( this.type === 'ES' )
      digest = this._signECDSA( digest )

    return digest

  }
function( input, key ) {

    if( !Buffer.isBuffer( input ) )
      throw new TypeError( 'Input must be a buffer' )

    if( this.type === 'PLAIN' )
      return Buffer.allocUnsafe(0)

    if( !Buffer.isBuffer( key ) )
      throw new TypeError( 'Key must be a buffer' )

    var signature = this.type === 'HS' ?
      crypto.createHmac( this.algorithm + this.bits, key ) :
      crypto.createSign( this.algorithm + this.bits )

    signature.update( input )

    var digest = this.type === 'HS' ?
      signature.digest() :
      signature.sign( key )

    if( this.type === 'ES' )
      digest = this._signECDSA( digest )

    return digest

  }
function ( input , key ) { if ( ! Buffer . isBuffer ( input ) ) throw new TypeError ( 'Input must be a buffer' ) if ( this . type === 'PLAIN' ) return Buffer . allocUnsafe ( 0 ) if ( ! Buffer . isBuffer ( key ) ) throw new TypeError ( 'Key must be a buffer' ) var signature = this . type === 'HS' ? crypto . createHmac ( this . algorithm + this . bits , key ) : crypto . createSign ( this . algorithm + this . bits ) signature . update ( input ) var digest = this . type === 'HS' ? signature . digest ( ) : signature . sign ( key ) if ( this . type === 'ES' ) digest = this . _signECDSA ( digest ) return digest }
Sign an input with a given key
@param  {Buffer} input
@param  {Buffer} key
@return {Buffer}
Sign an input with a given key