R – How to combine n and e to create the public key in RSA

public-key-encryptionrsa

I have a 128-byte (1024-bit) modulus (in a byte array format) and my exponent (also in a byte array format). I need to create a 128-byte array representing the public key.

According to Wikipedia, "The public key consists of the modulus n and the public (or encryption) exponent e." But that doesn't tell me how to mix both.

What is the right operation to do?
– n^e (will that stay 128 bytes long?)
– just n?
– n followed by e?
– n added to e?
– something else?

Best Answer

You won't be able to create such an array. The "public key" has two parts: the exponent and the modulus. They are separate numbers that must be kept separate, since both are needed to perform encryption and decryption later on. Although your n is 1024 bits, the public key altogether is necessarily longer.

Related Topic