Posted 08 April 2015 - 03:41 AM
Hey guys,
currently I am working on a rsa api, but there is a little problem in the encryption part. The decryption is working fine. Here is my method:
The example key is:
If I now want to encrypt 123 [ code: encrypt(pub,123) ], then i get "nan" as the output.
I am at an integer limit? i think the limit was at 2^52 ?
currently I am working on a rsa api, but there is a little problem in the encryption part. The decryption is working fine. Here is my method:
function div(a,B)/>
return (a-math.floor(a/B)/>*B)/>
end
function encrypt(key,m)
local c = div(math.pow(m,key.e),key.n)
return c
end
The example key is:
pub = {
e = 101213,
n = 108419
}
priv = {
d = 54917,
n = 108419
}
If I now want to encrypt 123 [ code: encrypt(pub,123) ], then i get "nan" as the output.
I am at an integer limit? i think the limit was at 2^52 ?