I set myself a task to write a minimal number of lines to implement a full RSA key generation, encryption and…