RSA is actually very simple

Source: Internet
Author: User

RSA is actually very simple:
1. Select two prime numbers p and q.
2. calculate n = PQ
3. Select E, so that E and (p-1) (q-1)
4. calculate d = e ^ (-1) mod (p-1) (q-1 ))
N, e is the RSA public key. You need to tell everyone who may send encrypted information,
D is the private key, only you can know.
But when someone wants to send the message m, they need to use the encryption algorithm to convert the plaintext m to the secret C
C = m ^ (E) (mod N)
After you receive the confidential C, use the decryption algorithm to convert the plaintext m
M = C ^ (D) (mod N)

Copy an example:
Take: P = 47 q = 71
So: N = PQ = 3337 P-1) (q-1) = 3220
Take: E = 79
So: D = 79 ^ (-1) mod 3220 = 1019
Encrypted plaintext M = 688
C = 688 ^ (79) (mod 3337) = 1570
Decrypt ciphertext c = 1570
M = 1570 ^ (1019) (mod 3337) = 688

That's simple. However, for security purposes, both p and q are required to be large, generally at least bits,
The generated RSA key is 1024bit.

But if you want to make it a registration code algorithm, you must put all N, E, and D in the program,
This is no different from common symmetric key algorithms.

This program is used to select P, Q, and E. These numbers are generally randomly generated, and
Verify if it is valid.

E can be fixed to 65537, which has no effect on the encryption effect.

 

As you can see, RSA keys are not randomly selected. They are two prime numbers from p and q.
The calculated p and q numbers must be kept strictly confidential after the keys are obtained. It is best to discard them.
RSA Security is based on the difficulty of big number decomposition, that is to say, from N to reverse obtain p, q
There is no good method before, beyond the computing power of the current computer.
Once the big data decomposition problem is solved, RSA will lose its meaning.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.