can someone post algorithm wich will encrypt data with rsa?
please.
can someone post algorithm wich will encrypt data with rsa?
please.
It's not really an algoritm, its math:
Encryption:
c = m ^e (mod n)
Decryption
m = c ^e (mod n)
Where c is the encrypted message and m is the message.
For the exponent tibia uses 65537.
n is the private / public key.
Tibias public key is 12471045942682794300437644989798558216780170796069 70371640449048629485693808504213969045976869538770 22394604239428185498284169068581802277612081027966 72433631944853781144171907648434092285492927351730 86613707271053828991189994038080458464446472844991 23164879035103627004668521005328367415259939915284 902061793
It might also be handy to use OT keys if you're doing a proxy or something
OT public key is
10912013296739942927886096050899554152823750290279 81291234687579372662914925764463307396960011106039 07230888610072655818825358503429057592827629436413 10856602909362821263595383668656267584972062078627 94310902180176810615217550567108238764764442605581 47179707119674283982419152118103759076030616683978 566631413
OT private key is
46730330223584118622160180015036832148732986808519 34467521055526294025873980576686022461064691960586 02063280243267033616301098884178392419595075722472 84807035235569619173792292786907845791904955103601 65282251912190836718788550927002538864170082173534 52220879405783812108791168230137768089757668518290 20659073
Hope this helps
you will need a library(like GMP) or write your own "class" for big integers and you can see how it is done checking ot's sources
does it work in-place mode?
of after multiplying it 65k times i have to save all used memory? or just as much bytes as i used for calculation? i belive it is in-place, bacause client send < 200 bytes, not < 200 tera bytes.
and plz next time write those keys in hex
because its easier (WAY EASIER) to fill memory with hex values than non-hex.
i have to convert this to hex, and then fil memory from wich i will read them to make div. in hex you know that 2 characters = 1 byte, in this you dont.
what is wrong in this code? why it doesnt work?
Code:def modexp ( t, u, n ): s = 1 while u: if u & 1: s = (s * t)%n u >>= 1 t = (t * t)%n; return s a = 0x124 a = modexp(a, 65537, 109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110603907230888610072655818825358503429057592827629436413108566029093628212635953836686562675849720620786279431090218017681061521755056710823876476444260558147179707119674283982419152118103759076030616683978566631413); a = modexp(a, 65537, 46730330223584118622160180015036832148732986808519344675210555262940258739805766860224610646919605860206328024326703361630109888417839241959507572247284807035235569619173792292786907845791904955103601652822519121908367187885509270025388641700821735345222087940578381210879116823013776808975766851829020659073); print(hex(a));
Can python handle an integer that big without using special classes?
Certainly Python can handle such integers. But why reimplement the wheel when modular exponentiation is built in (as the pow() function)?
Nevertheless, this version of modexp looks sensible. Looks like you're trying to test it by encrypting and decrypting 0x124, but I think you used the wrong decryption key.
Edit: I meant that 46730... is the private exponent; the modulus remains the same as for encryption. Try
a = modexp(a, 65537, 10912[snip]31413);
a = modexp(a, 46730[snip]59073, 10912[snip]31413);
http://cisnet.baruch.cuny.edu/holowc.../9444/rsademo/
key is ok, works here.
modex implementation is i belive also fine, so where is the problem?Code:def modexp ( t, u, n ): s = 1 while u: if u & 1: s = (s * t)%n u >>= 1 t = (t * t)%n; return s a = 0x61616161616161616161 a = modexp(a, 65537, 109120132967399429278860960508995541528237502902798129123468757937266291492576446330739696001110603907230888610072655818825358503429057592827629436413108566029093628212635953836686562675849720620786279431090218017681061521755056710823876476444260558147179707119674283982419152118103759076030616683978566631413); a = modexp(a, 65537, 46730330223584118622160180015036832148732986808519344675210555262940258739805766860224610646919605860206328024326703361630109888417839241959507572247284807035235569619173792292786907845791904955103601652822519121908367187885509270025388641700821735345222087940578381210879116823013776808975766851829020659073); print(hex(a));
i tried everything, or maybe it works and i dont know how to read result? But i think i should get 0x61616161... at the ent. Rest nulls.