As we can guess by the name our project is a working example of RSA Algorithm and the motive was to encrypt any image with the help of RSA and decypt it. Actually I got this idea from steganography which is basically a techinique to encode a image with a piece of information although the project is far away from that but it's just the beginning.
When image is taken as input its properties will be displayed i.e. image size, file name and image resolution. After this Hex function will extracts image Hex code and then it is going to convert in cipher text through RSA Algorithm. When this cipher text will be loaded and applied RSA Algorithm, it will decipher the text, and the image is loaded back.
- Image input
- Loading image
- Hex conversion
- RSA algorithm to encrypt Cipher text
- Stop
- Cipher Text
- Input---> Loading cipher File
- RSA algorithm to decrypt
- Hex conversion
- Create a file
- Stop
-
RSA Algorithm (Ron Rivest, Adi Shamir, and Leonard Adleman Algorithm) In this project we have use the class RSA which we have used to multiple function such as calculating phi , Mod and value of n.
-
Cryptography: the image is encrypted using RSA and a cipher file is generated making it secure and unable to read with out the keys.
public static int cal_phi(int p1, int p2)
{
return ( (p1 - 1) * (p2- 1) );
}
public static long mod(int p, int q, int r)
{
if (p == 0)
return 1;
else if (p % 2 == 0)
return sqr(mod(p, q / 2, r)) % r;
else
return ((p % r) * mod(p, q - 1, r)) % r;
}
public static Int32 pvt_Key(int a, int b, int c)
{
int x = 0;
int RES = 0;
for (c = 1; ; c++)
{
RES = (c * b) % a;
if (RES == 1) break;
}
return c;
}
//This method converts the image file into cipher text files
public static int n_value(int p1, int p2)
{
return( p1 * p2);
}
this was the first time we were trying to convert image into bytes though we know that image consist of several pixels and each pixel has a different value we used the logic to convert the image into bytes also we took help from internet from a website and also youtube refrences are mentioned below.
identifying the value of D and N in Decyption was hard too so we took a help of a online calculator linked and process is also mentioned in the repository and below the document!.