src/crypto/hash/index.js
function(algo, data) {
    switch (algo) {
      case 1:
        // - MD5 [HAC]
        return this.md5(data);
      case 2:
        // - SHA-1 [FIPS180]
        return this.sha1(data);
      case 3:
        // - RIPE-MD/160 [HAC]
        return this.ripemd(data);
      case 8:
        // - SHA256 [FIPS180]
        return this.sha256(data);
      case 9:
        // - SHA384 [FIPS180]
        return this.sha384(data);
      case 10:
        // - SHA512 [FIPS180]
        return this.sha512(data);
      case 11:
        // - SHA224 [FIPS180]
        return this.sha224(data);
      default:
        throw new Error('Invalid hash function.');
    }
  }
function(algo, data) {
    switch (algo) {
      case 1:
        // - MD5 [HAC]
        return this.md5(data);
      case 2:
        // - SHA-1 [FIPS180]
        return this.sha1(data);
      case 3:
        // - RIPE-MD/160 [HAC]
        return this.ripemd(data);
      case 8:
        // - SHA256 [FIPS180]
        return this.sha256(data);
      case 9:
        // - SHA384 [FIPS180]
        return this.sha384(data);
      case 10:
        // - SHA512 [FIPS180]
        return this.sha512(data);
      case 11:
        // - SHA224 [FIPS180]
        return this.sha224(data);
      default:
        throw new Error('Invalid hash function.');
    }
  }
function ( algo , data ) { switch ( algo ) { case 1 : // - MD5 [HAC] return this . md5 ( data ) ; case 2 : // - SHA-1 [FIPS180] return this . sha1 ( data ) ; case 3 : // - RIPE-MD/160 [HAC] return this . ripemd ( data ) ; case 8 : // - SHA256 [FIPS180] return this . sha256 ( data ) ; case 9 : // - SHA384 [FIPS180] return this . sha384 ( data ) ; case 10 : // - SHA512 [FIPS180] return this . sha512 ( data ) ; case 11 : // - SHA224 [FIPS180] return this . sha224 ( data ) ; default : throw new Error ( 'Invalid hash function.' ) ; } }
Create a hash on the specified data using the specified algorithm
@param {module:enums.hash} algo Hash algorithm type (see {@link https://tools.ietf.org/html/rfc4880#section-9.4|RFC 4880 9.4})
@param {Uint8Array} data Data to be hashed
@returns {Promise<Uint8Array>} hash value
Create a hash on the specified data using the specified algorithm