text: /**
   * Define digest function.
   * @function digest
   * @param {string} spec - Password spec
   * @returns {function} digest function
   */
  
  'use strict'
  
  const uuid = require('uuid')
  const {
    fromSpecString,
    DEFAULT_ALGORITHM, DEFAULT_ITERATIONS, DEFAULT_LENGTH
  } = require('apasswd')
  
  const DEFAULT_SPEC = [
    DEFAULT_ALGORITHM,
    DEFAULT_ITERATIONS,
    DEFAULT_LENGTH
  ].join(':')
  
  /** @lends digest */
  function digest (spec) {
    let passwd = fromSpecString(spec || DEFAULT_SPEC)
  
    /**
     * Define digest
     * @param {string} password
     * @param {string} salt
     * @returns {Promise}
     */
    function digestImpl (password, salt) {
      return passwd.digest(password, salt)
    }
  
    Object.assign(digestImpl, {
      newSalt () {
        return uuid.v4()
      }
    })
  
    return digestImpl
  }
  
  module.exports = digest
  