class Argon2::Engine

def self.hash_argon2i_encode(password, salt, t_cost, m_cost, secret)

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