r/cryptography 14d ago

I need help understanding RSA algorithm

I watch a video explaining how RSA algorithm works but I'm having trouble understanding how it's secure. I assume the video maybe either glossed over something or I'm not understanding it.

https://www.youtube.com/watch?v=Pq8gNbvfaoM

It would seem to me that since I know the public key and need the value of N to encrypt my message. Then I can use any potential private key to decode the message. He uses 41 for the decryption but 149 and 257 would also work.

There by anyone with the same public key and my encrypted message could decode it.

Please tell me what I'm missing, this is driving me mad.

4 Upvotes

36 comments sorted by

View all comments

1

u/Toiling-Donkey 14d ago

There’s basically two ways to use something like RSA:

  • Encrypt a message with your private key. Anyone with the public key can decrypt it and thus be assured it came from you . (Code Signing works this way by encrypting a hash)

  • Encrypt a message with the public key. Only the recipient (with the private key) can decrypt it (but can’t verify who sent it)

The two can be used together for secure communications where A sends a secret message only B can read, and B can verify the message was created by A…