Updated 24 Aug 2020
RSA encryption using Optimal Asymmetric Encryption Padding with matlab which encrypts and dycrypts text in a query file.
you will need only the vpi package: https://www.mathworks.com/matlabcentral/fileexchange/22725-variable-precision-integer-arithmetic
RSA is a famous encryption-decryption system which is oftenly used along with the OAEP to ensure the security of the data.
Using random n bits primes the rsa is encrypting a messege after the OAEP converts the charachters uint8 representation to random encoding using random-oracle hash functions like SHA-256 which is used here.
the RSA then uses the two random primes to generate the public and the private keys, encrypt the messege with the public key save it in a file and then decrypt it in another file using the private key to get the numbers generated by the OAEP earlier on the sender side.
The OAEp decrypts the messege and gets the original messege back and saves it in a folder.
* The code is slow as the vpi package takes a big time in calculations.
You can try using one of the alternatives in this post to boost speed: https://www.mathworks.com/matlabcentral/answers/116949-big-integer-speed-vpi-and-symbolic
* The function isprime can be further improved to make the time costly check more fast or to use prior check different than fermat's little theorem that is more percise.
This link can be helpful: https://www.geeksforgeeks.org/prime-numbers/ (I suggest using Lucas test)
Ahmed Salah (2023). RSA-OAEP-matlab (https://github.com/AhmedSalah339/RSA-OAEP-matlab/releases/tag/V1.1.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
See release notes for this release on GitHub: https://github.com/AhmedSalah339/RSA-OAEP-matlab/releases/tag/V1.1.0