class Argon2::Engine

def self.hash_argon2id_encode(password, salt, t_cost, m_cost, p_cost, secret)

def self.hash_argon2id_encode(password, salt, t_cost, m_cost, p_cost, secret)
  result = ''
  secretlen = secret.nil? ? 0 : secret.bytesize
  passwordlen = password.nil? ? 0 : password.bytesize
  raise ArgonHashFail, "Invalid salt size" if salt.length != Constants::SALT_LEN
  FFI::MemoryPointer.new(:char, Constants::ENCODE_LEN) do |buffer|
    ret = Ext.argon2_wrap(buffer, password, passwordlen,
                          salt, salt.length, t_cost, (1 << m_cost),
                          p_cost, secret, secretlen)
    raise ArgonHashFail, ERRORS[ret.abs] unless ret.zero?
    result = buffer.read_string(Constants::ENCODE_LEN)
  end
  result.delete "\0"
end