Steam Auth/RSA encryption help

Hello! I’m trying to port to Garry’s Mod, but I can’t encrypt my password properly.

Here is my code:

function getrsakey(username, password)

		method = "get",
		url = "",

		parameters = {
			["username"] = username,

		success = function(_, body)
			local parsed = util.JSONToTable(body)
			if !parsed or !parsed.success then error('getrsakey():
	'..body) end

			rsaPublicMod = parsed.publickey_mod
			rsaPublicExp = parsed.publickey_exp
			steamTimestamp = parsed.timestamp

			-- encrypting password
			local encryptedPassword = rsa.crypt(rsaPublicMod, rsaPublicExp, password) -- here's the line I'm stuck at
			encryptedPassword = util.Base64Encode(encryptedPassword)

			login(encryptedPassword, username, steamTimestamp)

Currently I’m using this RSA library. (I’m sure I fucked it up a lot)
It’s a modified version of this one.

I get this error:

[ERROR] lua/includes/modules/rsa.lua:153: attempt to perform arithmetic on local 'n' (a nil value)
  1. addint - lua/includes/modules/rsa.lua:153
   2. bigint - lua/includes/modules/rsa.lua:473
    3. crypt - lua/includes/modules/rsa.lua:929
     4. unknown - lua/sv_steam.lua:84

Thanks for your help!

Check the arguments you’re passing to rsa.crypt() – it looks like rsaPublicMod or rsaPublicExp don’t contain valid numbers?
rsaPublicMod = assert(tonumber(parsed.publickey_mod), parsed.publickey_mod)
rsaPublicExp = assert(tonumber(parsed.publickey_exp), parsed.publickey_exp)

The arguments are OK, may be it’s their order though.