Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RSA key encoding?

Status
Not open for further replies.

lold00d

Programmer
Joined
Jan 28, 2008
Messages
1
Location
US
I was wondering just what type of encoding i would need to use in order to manually encrypt/decrypt messages. I have a modulus, and both exponents, but both are in 2-byte format. the modulus is 2048-bits long, and i don't know what i would need to convert it to in order to manually encrypt/decrypt my messages.

Mainly, i developed a system where i generate a SHA1 hash of a file, and encrypt it with my public keypair, and then before loading the file i would run a SHA1 hash again, and decrypt the stored hash, and check both of them to see if they're both the same. Now I have a couple problems with this.

firstly, my SHA1 hash is supposed to be 20-bytes long, but i get 40-bytes (possibly 2-byte hex?), and secondly, my modulus is in 2-byte hexadecimal format, but my exponents aren't.

Now i want to be able to manually encrypt messages, and decrypt messages (I have a special need for doing it manually) using the formula:

encrypt(T) = (T^E) mod PQ
T = result, E=public exponent, PQ = modulus.
so i think that i need to convert it to a decimal format?

such as the example from this site:
uses smaller exponents, and a smaller modulus, mine's much larger, i just need it to be an integer, or whatever type of number is used.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top