Reputation: 11
I'm trying to replicate some encryption methods in Lua and Lua doesn't like big numbers. For example:
print(6219^3445) > inf
Does anybody know a way around this?
Upvotes: 0
Views: 593
Reputation: 3113
Well. A really stupid (but effective) way could be to hold your numbers in strings, and in math operations deal with each digit separately. Concatenate for tostring.
Upvotes: 0
Reputation: 18410
You could use a Lua-Library like: http://oss.digirati.com.br/luabignum/
For encryption, you might want to have a look at the openssl-bindings for lua, perhaps these already contain what you are trying to implement: http://luacrypto.luaforge.net/ or https://github.com/zhaozg/lua-openssl
Upvotes: 4