File Exchange

image thumbnail

RSA algorithm

version 1.1.0.0 (1.47 KB) by suriyanath
RSA algorithm for encrypting and decrypting a message

39 Downloads

Updated 17 Sep 2016

View Version History

View License

This code asks for Two prime numbers and then computes Public and Private key. Then the message is encrypted using Public key and decrypted using Private key. An example is shown in figure.

Cite As

suriyanath (2021). RSA algorithm (https://www.mathworks.com/matlabcentral/fileexchange/46824-rsa-algorithm), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

EN T

In the higher version,you should use randi to replace randint ,and modify the position of the input varible.
my version is 2020a
error:
n1=randint(1,1,n);
e=randint(1,1,[2 n1]);
correct:
n1=randi(n,1,1);
e=randi([2 n1],1,1);

wang

No funciona. same to me.
Error in rsa_code (line 15)
e=randi(1,1,[2 n1]);

Juan David Peña Melo

No funciona.

Error in rsa_code (line 15)
e=randi(1,1,[2 n1]);

Islam Adam

Ugwulayinka

How do I use this code to encrypt files?

dahmouni lyes

fang zheng

M. Arif Rahman

thank you..

Tim Kaufmann

missing a function, is this in an additional toolbox or base matlab is ok.
I'm using 2015b.

Undefined function or variable
'randint'.

Antonio Afta

khurria zafar

rh

you should use extended eucleudianalgorithm to search for d.
this implementation is incorrect
dec(enc(msg)) != msg

jafar hassanpour

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!