You are on page 1of 17

ASSIGNMENT-1

USN: B(1MJ16CS106) name: Prerna Panda


Class: 6B(CS)

EncDec.java
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Scanner;

public class EncDec {


int flag=0,shiftby=2;String key="";
double percent;
Scanner inputscanner =new Scanner(System.in);

void encrypt(String filename,String dirname,String key) //encrypt function


{
try{
File dir = new File("TempFiles");
if(!dir.exists())
dir.mkdir(); //make a folder(if donot exist) for temporary files which will b deleted
at end of prg
RandomAccessFile fn = new RandomAccessFile(filename, "rw");
RandomAccessFile in = new RandomAccessFile("TempFiles/cp-temp.txt", "rw");
RandomAccessFile outTemp = new RandomAccessFile("TempFiles/enc-T.txt", "rw");
RandomAccessFile out = new RandomAccessFile(dirname+"/enc.txt", "rw");

FunctionSet.copyFile(filename, "TempFiles/cp-temp.txt");//Faster FileCopy using File Channels

FunctionSet.rounds(in, outTemp, key, shiftby,"Encrypting"); //xor

FunctionSet.shuffle(outTemp, out); //shuffle

File f1 = new File("TempFiles/cp-temp.txt");


File f2 = new File("TempFiles/enc-T.txt");
f1.delete();f2.delete();

fn.close();in.close();out.close(); //Release Resources


}
catch ( IOException e) {
System.out.println(e);
}
}

void decrypt(String filename,String extname, String dirname,String key) //decrypt fxn


{
try{
File dir = new File("TempFiles");
if(!dir.exists())
dir.mkdir(); //make a folder(if donot exist) for temporary files which will b deleted
at end of prg

RandomAccessFile fn = new RandomAccessFile(filename, "rw");


RandomAccessFile in = new RandomAccessFile("TempFiles/cp-temp.txt", "rw");
RandomAccessFile out = new RandomAccessFile(dirname+"/dec."+extname, "rw");

FunctionSet.shuffle(fn, in); //deshuffle


FunctionSet.rounds(in, out, key, shiftby,"Decrypting"); //xor

File f = new File("TempFiles/cp-temp.txt");


f.delete();
System.out.println("Do you want to delete "+filename+"?\nEnter 1 for yes and 2 for No:");
int opt=0;
if(inputscanner.hasNextInt())
{
opt=inputscanner.nextInt();
FunctionSet.delencf(filename,opt);
}
else
System.out.println("Wrong Option!");
//release resources
in.close();out.close();fn.close();
}
catch ( IOException e) {
System.out.println(e);
}
}

FunctionSet.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.Random;
import java.util.Scanner;

public class FunctionSet {


Scanner inscan=new Scanner(System.in);

public static void xor(RandomAccessFile in,RandomAccessFile temp,String key,String mode,String round)


{

int len_var=0;
try
{
long incount=in.length();int p=0;double percent;
in.seek(0);
temp.seek(0);
for(int j=0; j<=incount-1;j++)
{
int intchr=in.read();
//write at beginning
temp.write(intchr^key.charAt(len_var));
len_var++;
if(len_var>key.length()-1)
len_var=0;
percent=percentage(p,incount);
p++;
System.out.println("["+round+"]"+" "+mode+" Characters to File:"+percent + "%");
}
}
catch(Exception e){
}
}
public static void shuffle(RandomAccessFile in,RandomAccessFile out)
{

try {
int p=0;
long count=in.length();

for(long i=count-1;i>=0;i--)
{
//Writing on file>>
in.seek(i); //set cursor of in file at last >> i=count-1
out.seek(p); //set cursor of output file to start >> p=0
int ch =in.read(); //read() from in
out.write(ch); //write it at start of output file
p=p+1; //increment p

}
} catch (IOException e) {
System.out.println(e);
}

public static int check(String filename)


{
int flag=0;
File filechk = new File(filename);
if(filechk.isFile())
flag=1;
else if(filechk.isDirectory())
flag=2;
if(flag!=1&&flag!=2)
System.out.println("'"+filename+"'"+" is not a Valid FILE/DIRECTORY!");
return flag;

public static double percentage(long no, long total) //percent function


{
double per = (no*100.0)/total;
per = per * 100;
per = Math.round(per);
per = per/100;
return per;
}

public static void openfile(String filename)


{
try {
RandomAccessFile in=new RandomAccessFile(filename,"r");
int check=0;
while(check==0)
{
String str=in.readLine();
if(str==null)
{ check=1;
break;
}
else
System.out.println(str);

}
in.close();
} catch (IOException e) {
System.out.println(e);
}

public static void delencf(String filename, int ch)


{
if(ch==1)
{
File f = new File(filename);
if(f.delete())
System.out.println(filename+" deleted Successfully!");
else
System.out.println("\nCouldn't Locate "+filename+" to delete!");
}
}

public static String shiftKey(String key,int shiftby) //left shift by factor "shiftby'
{

int keylen=key.length();
String s1=key.substring(shiftby,keylen);
String s2=key.substring(0,shiftby);
key=s1+s2;
return key;
}

public static void rounds(RandomAccessFile in,RandomAccessFile out,String key,int shiftby,String mode)


//round Encryption/decryption
{
FunctionSet obj=new FunctionSet();

int round=0,ch=0;
String roundname="";
System.out.println("=========================================================================");
System.out.println("Enter Mode:\n1.FAST(2 Round Enc/Dec)\t\t--Estimated Time :: "+EstTime(in,2)+" seconds
("+(EstTime(in,2))/60+" minutes)\n2.FASTER(4-R E/D)\t\t--Estimated Time :: "+EstTime(in,4)+" seconds ("+
(EstTime(in,4))/60+" minutes)\n3.STANDARD(8-R E/D)\t\t--Estimated Time :: "+EstTime(in,8)+" seconds ("+
(EstTime(in,8))/60+" minutes)\n4.STANDARD-Plus(12-R E/D)\t--Estimated Time :: "+EstTime(in,12)+" seconds
("+(EstTime(in,12))/60+" minutes)\n5.EXPRESS(16-R E/D)\t\t--Estimated Time :: "+EstTime(in,16)+" seconds
("+(EstTime(in,16))/60+" minutes)\n\t\tUse Same Mode for Decryption with which the File was ENcrypted!");
System.out.println("=========================================================================");
if(obj.inscan.hasNextInt())
ch=obj.inscan.nextInt();

if(ch==1){
round=2;
roundname="2 Round Enc/Dec";
}
else if(ch==2){
round=4;
roundname="4 Round Enc/Dec";
}
else if(ch==3){
round=8;
roundname="8 Round Enc/Dec";
}
else if(ch==4)
{round=12;
roundname="12 Round Enc/Dec";
}
else if(ch==5){
round=16;
roundname="16 Round Enc/Dec";
}
else
System.out.println("Invalid Option!");

if(key.length()%2!=0)
round--;

for(int i=1;i<=round;i++) //Apply Alternate rounds


{

if(i%2!=0)
{
System.out.println("\t\t\tROUND--"+i);
key=FunctionSet.shiftKey(key,shiftby);
FunctionSet.xor(in, out, key,mode,"Round-"+i);
}
else
{
System.out.println("\t\t\tROUND--"+i);
key=FunctionSet.shiftKey(key,shiftby);
FunctionSet.xor(out, in, key,mode,"Round-"+i);
}
}
System.out.println("\t\t\t"+roundname+ " Successfully Completed!");

public static double EstTime(RandomAccessFile inputfn, int rounds)


{

//File input=new File(inputfn);


double bytes=0;
try {
bytes = inputfn.length();
} catch (IOException e) {
System.out.println(e);
}
double kb=bytes/1024;

kb=kb*100000;
kb=Math.round(kb);
kb=kb/100000; //file size in kb with 5 decimal places only
double ests=(kb/58.5)*rounds; //estimated seconds-->ANALYSIS=58.5kb take 1 sec
ests=ests*100000;
ests=Math.round(ests);
ests=ests/100000;

/* double estm=ests/60; //estimated minutes


estm=estm*10000;
estm=Math.round(estm);
estm=estm/10000; //estminutes with only upto 5 decimal places
*/
return ests;
}

public static void copyFile(String source, String dest) throws IOException //using
File channel=>faster method
{
File src=new File(source);
File dst=new File(dest);
FileChannel sourceCh = null;
FileChannel destCh = null;
try {
sourceCh = new FileInputStream(src).getChannel();
destCh = new FileOutputStream(dst).getChannel();
destCh.transferFrom(sourceCh, 0, sourceCh.size());

}
finally{
sourceCh.close();destCh.close();
}
}

public static String KeyGen(String key) //make a 200 byte key from user key
{
int len=key.length(),i=0,n=1;
do{
int x= key.charAt(i)+n; //more randomness by 'n'
key+=x;
n++;i++;

if(i==len-1)
i=0;
}while(key.length()<len+100);
key=key.substring(len, key.length());

int [] kArray=new int[key.length()];


for(int m =0;m<=key.length()-1;m++)
{
kArray[m]=key.charAt(m);
System.out.println("Generating 200 byte key from Entered key: "+FunctionSet.percentage(m, key.length()-
1)+"%");
}

int kArrLen=kArray.length;
for (int j = kArrLen - 1; j >= 1; j--) //FISHER-YATES Random Shuffle
{
Random rand = new Random();
// generate a random number k such that 0 <= k <= j
int k = rand.nextInt(j + 1);

// swap current element with randomly generated index


int temp = kArray[j];
kArray[j] = kArray[k];
kArray[k] = temp;
}

key="";
for(int m =0;m<=kArrLen-1;m++)
{
key+=kArray[m];
}
System.out.println(key.length()+" Byte Key Generated Successfully!");
return key;
}
}

RsaFunctionClass.java
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.util.Date;
//import java.util.Random;

public class RsaFunctionClass {

static BigInteger p=new


BigInteger("1017052001881606000223919802064606361744081396368380654263375293786254264836413604591749903010
5022294024748804238597402254039985100236404965190482708142187368697889253048207221223624582229342521261263
408791744763793516074597040299901138703006171350895659687883491657934523458832379876478944697004728249" );
static BigInteger q=new
BigInteger("6538485182967967681002944134671339894206673047620489057461415934169800822166879906242455231033
7145407218777076121201166597398331294181931520020759996089676621992438490999875828665545556092017520061383
73531748395312746018907257771132455712299919934506048310864324009318877056820609330530982612021213");
static BigInteger e=new
BigInteger("6828972640182135118746016131596780415865452604497990610085654097728892288639537523547809894460
2349609887287239630258319526027236288000611383999266250593156809943073247617304071174760941868877908602556
91652271759632373671008310448893399963176826806453367498895202162462213762974300039819212045848589714261" )
;
static BigInteger n = p.multiply(q);
static BigInteger phi=phi(p,q);
static BigInteger d = privateKey(e, phi);
//Calculate phi(p,q)=(p-1)(q-1)
static public BigInteger phi(BigInteger p,BigInteger q)
{
BigInteger pMinusOne=p.subtract(BigInteger.ONE); //p-1
BigInteger qMinusOne=q.subtract(BigInteger.ONE); //q-1
phi=pMinusOne.multiply(qMinusOne); //phi=(p-1)(q-1)
return phi;
}

// Compute the private key 'd' from Public key 'e' and phi
private static BigInteger privateKey(BigInteger e, BigInteger phi) {

BigInteger elocal = e;
BigInteger philocal = phi;
BigInteger xOld = new BigInteger("1");
BigInteger yOld = new BigInteger("0");
BigInteger x = new BigInteger("0");
BigInteger y = new BigInteger("1");
BigInteger xNew, yNew, q, r;
BigInteger zero = new BigInteger("0");

// Extended Euclidean algorithm


while(!philocal.equals(zero)) //phi!=0
{
q = elocal.divide(philocal); //quotient=e/phi
r = elocal.mod(philocal); //remainder=e%phi
xNew = xOld.subtract(q.multiply(x));
yNew = yOld.subtract(q.multiply(y));
elocal = philocal;
philocal = r;
xOld = x;
yOld = y;
x = xNew;
y = yNew;
}

// We want d to be positive
// if xOld is less than zero we add it to x else, we just return it
if(xOld.compareTo(zero) == -1) {
return xOld.add(x);
}
return xOld;

}
static public BigInteger EncDec(BigInteger m_c, BigInteger e_d, BigInteger n)
{
BigInteger zero = new BigInteger("0");
BigInteger one = new BigInteger("1");
BigInteger two = one.add(one);

// Base Case
if (e_d.equals(zero))
return one; //m^e mod n-->e=0
if (e_d.equals(one))
return m_c.mod(n); //m^e mod n-->e=1

if (e_d.mod(two).equals(zero)) {
// Calculates the square root of the answer
BigInteger answer = EncDec(m_c, e_d.divide(two), n);
// Reuses the result of the square root
return (answer.multiply(answer)).mod(n);
}

return (m_c.multiply(EncDec(m_c,e_d.subtract(one),n))).mod(n);
}
public static String StrToBytes(String key)
{
byte[] bytekey =key.getBytes(Charset.defaultCharset());
key="";
for(int i=0;i<bytekey.length;i++)
{
byte b=bytekey[i];
key+=b; //cancatenate bytes
}
return key;
}

public static String BytesToStr(byte [] bkey)


{
String Skey =new String(bkey,Charset.defaultCharset());
return Skey;
}

public static String WriteEncKey(BigInteger Enkey,String dirname,String filename)


{
String returnname="",name="";
filename=filename.substring(filename.lastIndexOf("/")+1);
if (filename.contains("."))
name="Key-"+filename.substring(0,filename.lastIndexOf("."))+".txt";
else
name="Key-"+filename+".txt";

Date dt=new Date();


try
{
File ptr=new File(dirname+"/"+name);
if(ptr.exists())
{
RandomAccessFile out=new
RandomAccessFile(dirname+"/"+"Key-"+filename.substring(0,filename.lastIndexOf("."))+"Copy"+".txt","rw");
out.seek(0);
out.writeBytes("Encrypted Key for File : "+filename+" Generated on: "+dt+"\n\nNote: This is NOT the
Secret(private) Key, but Just the RSA Encrypted Cipher text\nNo Need To keep It a secret:)\n\n"+Enkey);
out.close();
returnname=dirname+"/"+"Key-"+filename.substring(0,filename.lastIndexOf("."))+"Copy"+".txt";
}
else
{
RandomAccessFile out=new RandomAccessFile(dirname+"/"+name,"rw");
out.seek(0);
out.writeBytes("Encrypted Key for File : "+filename+" Generated on: "+dt+"\n\nNote: This is NOT the
Secret(private) Key, but Just the RSA Encrypted Cipher text\nNo Need To keep It a secret:)\n\n"+Enkey);
out.close();
returnname=dirname+"/"+name;
}

} catch (IOException e) {
System.out.println(e);
//e.printStackTrace();
}
return returnname;
}
}

Start.java
import java.math.BigInteger;
import java.util.Scanner;

public class start {


static boolean flag=true;
static String filename="",dirname="",key="";
static int chk=0,ch=0;
//static byte [] bkey;

public static void main(String[] args) {


EncDec obj=new EncDec();
Scanner chscanner =new Scanner(System.in);

while(flag)
{
System.out.println("\n===============================================================\n 1.ENCRYPT a
file \t 2.DECRYPT a file \t 3.Open a File\n 4.Delete a File \t 5.Exit
Program\n===============================================================");
System.out.println("Enter Your Choice:\t");
if(chscanner.hasNextInt())
ch=chscanner.nextInt();
switch(ch)
{
case 1:
do {
System.out.println("Enter Name of the File to be Encrypted(include path if outside):");
filename=chscanner.next();
filename=filename.replaceAll("\\\\", "/"); //for windows dir scheme
chk=FunctionSet.check(filename);
}while(chk!=1);

do {
System.out.println("Enter Name of Directory to store Encrypted file:");
dirname=chscanner.next();
dirname=dirname.replaceAll("\\\\", "/");
chk=FunctionSet.check(dirname);
}while(chk!=2);

do{
System.out.println("Enter Your Private Key (length>10),And Forget it :)");
key=chscanner.nextLine();
if(key.length()<10)
System.out.println("\t\t--Private Key Size should be > 10!--");
}while(key.length()<10);

key=FunctionSet.KeyGen(key);
BigInteger m=new BigInteger(key); //convert to BI
BigInteger Enkey=RsaFunctionClass.EncDec(m, RsaFunctionClass.e,RsaFunctionClass.n); //RSA-Encrypt
the key
String keyloc=RsaFunctionClass.WriteEncKey(Enkey, dirname, filename); //write encrypted key to file
for further use

obj.encrypt(filename,dirname,key);

System.out.println("\nFile ENCRYPTED Successfully as 'enc.hades', Stored at"+"'"+dirname+"'");


System.out.println("ATTENTION! NOW Your Encrypted Private Key is:"+Enkey+"\n\tIt is Saved for You at
'"+keyloc+"'");
break;

case 2:
do
{
System.out.println("Enter Name of the Encrypted File that is to be Decrypted(include path if outside):");
filename=chscanner.next();
filename=filename.replaceAll("\\\\", "/");
chk=FunctionSet.check(filename);
}while(chk!=1);

//Get Original Extension for Decryption


System.out.println("Enter EXTENSION to which file is to be Decrypted(e.g txt,pdf,jpg,mp3,mp4,etc):");
String extname = chscanner.next();
extname=extname.substring(extname.lastIndexOf(".") + 1); //if user provided a '.' with extension
do{
System.out.println("Enter Name of Directory where Decrypted file will be Stored:");
dirname=chscanner.next();
dirname=dirname.replaceAll("\\\\", "/");
chk=FunctionSet.check(dirname);
}while(chk!=2);

String regex = "[0-9]+"; //Regular Expression for string to make sure key contains only numbers
do{
System.out.println("Enter Your Encrypted Private Key of the file:");
key=chscanner.next();
if(key.length()<500||!(key.matches(regex)))
System.out.println("\t\t--Encrypted-Key Size must be > 500 and Must only contain Numeric Values!");
}while((key.length()<500)||!(key.matches(regex)));

BigInteger c=new BigInteger(key); //convert to BI


BigInteger Deckey=RsaFunctionClass.EncDec(c, RsaFunctionClass.d,RsaFunctionClass.n); //UNHANDLED>>
make regex seq for key in EncDec fxn
//key=RsaFunctionClass.BytesToStr(bkey); //DEV..F
//System.out.println("Decrypted Private key is:"+key);
key=Deckey.toString();

obj.decrypt(filename,extname,dirname,key);

System.out.println("\nFile DECRYPTED Successfully as 'dec."+extname+",' Stored at "+"'"+dirname+"'");


break;

case 3:
do{
System.out.println("Enter Name of the File to be opened:");
filename=chscanner.next();
filename=filename.replaceAll("\\\\", "/");
chk=FunctionSet.check(filename);
}while(chk!=1);

FunctionSet.openfile(filename); //Static Call


break;

case 4:
System.out.println("Enter the name of the file you want to delete:");
String fname=chscanner.next();
fname=fname.replaceAll("\\\\", "/");
System.out.println("Do you want to delete the "+fname+" file! \nEnter 1 to Confirm and 2 to Abort:");
int opt=0;
if(chscanner.hasNextInt())
opt=chscanner.nextInt();
FunctionSet.delencf(fname,opt);
break;

case 5:
flag=false;
System.out.println("Good Bye!");
chscanner.close();
break;

default:
flag=false;
System.out.println("No Such Option... Good Bye!");
chscanner.close();
}
}
}
}

Filename.txt
This file will be encrypted.
Output
===============================================================
1.ENCRYPT a file 2.DECRYPT a file 3.Open a File
4.Delete a File 5.Exit Program
===============================================================
Enter Your Choice:
1
Enter Name of the File to be Encrypted(include path if outside):
filename.txt
Enter Name of Directory to store Encrypted file:
rsa
Enter Your Private Key (length>10),And Forget it :)
--Private Key Size should be > 10!--
Enter Your Private Key (length>10),And Forget it :)
1t364436786574657
Generating 200 byte key from Entered key: 0.0%
Generating 200 byte key from Entered key: 0.99%
Generating 200 byte key from Entered key: 1.98%
Generating 200 byte key from Entered key: 2.97%
Generating 200 byte key from Entered key: 3.96%
Generating 200 byte key from Entered key: 4.95%
Generating 200 byte key from Entered key: 5.94%
Generating 200 byte key from Entered key: 6.93%
Generating 200 byte key from Entered key: 7.92%
Generating 200 byte key from Entered key: 8.91%
Generating 200 byte key from Entered key: 9.9%
Generating 200 byte key from Entered key: 10.89%
Generating 200 byte key from Entered key: 11.88%
Generating 200 byte key from Entered key: 12.87%
Generating 200 byte key from Entered key: 13.86%
Generating 200 byte key from Entered key: 14.85%
Generating 200 byte key from Entered key: 15.84%
Generating 200 byte key from Entered key: 16.83%
Generating 200 byte key from Entered key: 17.82%
Generating 200 byte key from Entered key: 18.81%
Generating 200 byte key from Entered key: 19.8%
Generating 200 byte key from Entered key: 20.79%
Generating 200 byte key from Entered key: 21.78%
Generating 200 byte key from Entered key: 22.77%
Generating 200 byte key from Entered key: 23.76%
Generating 200 byte key from Entered key: 24.75%
Generating 200 byte key from Entered key: 25.74%
Generating 200 byte key from Entered key: 26.73%
Generating 200 byte key from Entered key: 27.72%
Generating 200 byte key from Entered key: 28.71%
Generating 200 byte key from Entered key: 29.7%
Generating 200 byte key from Entered key: 30.69%
Generating 200 byte key from Entered key: 31.68%
Generating 200 byte key from Entered key: 32.67%
Generating 200 byte key from Entered key: 33.66%
Generating 200 byte key from Entered key: 34.65%
Generating 200 byte key from Entered key: 35.64%
Generating 200 byte key from Entered key: 36.63%
Generating 200 byte key from Entered key: 37.62%
Generating 200 byte key from Entered key: 38.61%
Generating 200 byte key from Entered key: 39.6%
Generating 200 byte key from Entered key: 40.59%
Generating 200 byte key from Entered key: 41.58%
Generating 200 byte key from Entered key: 42.57%
Generating 200 byte key from Entered key: 43.56%
Generating 200 byte key from Entered key: 44.55%
Generating 200 byte key from Entered key: 45.54%
Generating 200 byte key from Entered key: 46.53%
Generating 200 byte key from Entered key: 47.52%
Generating 200 byte key from Entered key: 48.51%
Generating 200 byte key from Entered key: 49.5%
Generating 200 byte key from Entered key: 50.5%
Generating 200 byte key from Entered key: 51.49%
Generating 200 byte key from Entered key: 52.48%
Generating 200 byte key from Entered key: 53.47%
Generating 200 byte key from Entered key: 54.46%
Generating 200 byte key from Entered key: 55.45%
Generating 200 byte key from Entered key: 56.44%
Generating 200 byte key from Entered key: 57.43%
Generating 200 byte key from Entered key: 58.42%
Generating 200 byte key from Entered key: 59.41%
Generating 200 byte key from Entered key: 60.4%
Generating 200 byte key from Entered key: 61.39%
Generating 200 byte key from Entered key: 62.38%
Generating 200 byte key from Entered key: 63.37%
Generating 200 byte key from Entered key: 64.36%
Generating 200 byte key from Entered key: 65.35%
Generating 200 byte key from Entered key: 66.34%
Generating 200 byte key from Entered key: 67.33%
Generating 200 byte key from Entered key: 68.32%
Generating 200 byte key from Entered key: 69.31%
Generating 200 byte key from Entered key: 70.3%
Generating 200 byte key from Entered key: 71.29%
Generating 200 byte key from Entered key: 72.28%
Generating 200 byte key from Entered key: 73.27%
Generating 200 byte key from Entered key: 74.26%
Generating 200 byte key from Entered key: 75.25%
Generating 200 byte key from Entered key: 76.24%
Generating 200 byte key from Entered key: 77.23%
Generating 200 byte key from Entered key: 78.22%
Generating 200 byte key from Entered key: 79.21%
Generating 200 byte key from Entered key: 80.2%
Generating 200 byte key from Entered key: 81.19%
Generating 200 byte key from Entered key: 82.18%
Generating 200 byte key from Entered key: 83.17%
Generating 200 byte key from Entered key: 84.16%
Generating 200 byte key from Entered key: 85.15%
Generating 200 byte key from Entered key: 86.14%
Generating 200 byte key from Entered key: 87.13%
Generating 200 byte key from Entered key: 88.12%
Generating 200 byte key from Entered key: 89.11%
Generating 200 byte key from Entered key: 90.1%
Generating 200 byte key from Entered key: 91.09%
Generating 200 byte key from Entered key: 92.08%
Generating 200 byte key from Entered key: 93.07%
Generating 200 byte key from Entered key: 94.06%
Generating 200 byte key from Entered key: 95.05%
Generating 200 byte key from Entered key: 96.04%
Generating 200 byte key from Entered key: 97.03%
Generating 200 byte key from Entered key: 98.02%
Generating 200 byte key from Entered key: 99.01%
Generating 200 byte key from Entered key: 100.0%
204 Byte Key Generated Successfully!
=========================================================================
Enter Mode:
1.FAST(2 Round Enc/Dec) --Estimated Time :: 9.0E-4 seconds (1.5E-5 minutes)
2.FASTER(4-R E/D) --Estimated Time :: 0.0018 seconds (3.0E-5 minutes)
3.STANDARD(8-R E/D) --Estimated Time :: 0.00361 seconds (6.016666666666667E-5 minutes)
4.STANDARD-Plus(12-R E/D) --Estimated Time :: 0.00541 seconds (9.016666666666666E-5 minutes)
5.EXPRESS(16-R E/D) --Estimated Time :: 0.00721 seconds (1.2016666666666667E-4 minutes)
Use Same Mode for Decryption with which the File was ENcrypted!
=========================================================================
2
ROUND--1
[Round-1] Encrypting Characters to File:0.0%
[Round-1] Encrypting Characters to File:3.7%
[Round-1] Encrypting Characters to File:7.41%
[Round-1] Encrypting Characters to File:11.11%
[Round-1] Encrypting Characters to File:14.81%
[Round-1] Encrypting Characters to File:18.52%
[Round-1] Encrypting Characters to File:22.22%
[Round-1] Encrypting Characters to File:25.93%
[Round-1] Encrypting Characters to File:29.63%
[Round-1] Encrypting Characters to File:33.33%
[Round-1] Encrypting Characters to File:37.04%
[Round-1] Encrypting Characters to File:40.74%
[Round-1] Encrypting Characters to File:44.44%
[Round-1] Encrypting Characters to File:48.15%
[Round-1] Encrypting Characters to File:51.85%
[Round-1] Encrypting Characters to File:55.56%
[Round-1] Encrypting Characters to File:59.26%
[Round-1] Encrypting Characters to File:62.96%
[Round-1] Encrypting Characters to File:66.67%
[Round-1] Encrypting Characters to File:70.37%
[Round-1] Encrypting Characters to File:74.07%
[Round-1] Encrypting Characters to File:77.78%
[Round-1] Encrypting Characters to File:81.48%
[Round-1] Encrypting Characters to File:85.19%
[Round-1] Encrypting Characters to File:88.89%
[Round-1] Encrypting Characters to File:92.59%
[Round-1] Encrypting Characters to File:96.3%
ROUND--2
[Round-2] Encrypting Characters to File:0.0%
[Round-2] Encrypting Characters to File:3.7%
[Round-2] Encrypting Characters to File:7.41%
[Round-2] Encrypting Characters to File:11.11%
[Round-2] Encrypting Characters to File:14.81%
[Round-2] Encrypting Characters to File:18.52%
[Round-2] Encrypting Characters to File:22.22%
[Round-2] Encrypting Characters to File:25.93%
[Round-2] Encrypting Characters to File:29.63%
[Round-2] Encrypting Characters to File:33.33%
[Round-2] Encrypting Characters to File:37.04%
[Round-2] Encrypting Characters to File:40.74%
[Round-2] Encrypting Characters to File:44.44%
[Round-2] Encrypting Characters to File:48.15%
[Round-2] Encrypting Characters to File:51.85%
[Round-2] Encrypting Characters to File:55.56%
[Round-2] Encrypting Characters to File:59.26%
[Round-2] Encrypting Characters to File:62.96%
[Round-2] Encrypting Characters to File:66.67%
[Round-2] Encrypting Characters to File:70.37%
[Round-2] Encrypting Characters to File:74.07%
[Round-2] Encrypting Characters to File:77.78%
[Round-2] Encrypting Characters to File:81.48%
[Round-2] Encrypting Characters to File:85.19%
[Round-2] Encrypting Characters to File:88.89%
[Round-2] Encrypting Characters to File:92.59%
[Round-2] Encrypting Characters to File:96.3%
ROUND--3
[Round-3] Encrypting Characters to File:0.0%
[Round-3] Encrypting Characters to File:3.7%
[Round-3] Encrypting Characters to File:7.41%
[Round-3] Encrypting Characters to File:11.11%
[Round-3] Encrypting Characters to File:14.81%
[Round-3] Encrypting Characters to File:18.52%
[Round-3] Encrypting Characters to File:22.22%
[Round-3] Encrypting Characters to File:25.93%
[Round-3] Encrypting Characters to File:29.63%
[Round-3] Encrypting Characters to File:33.33%
[Round-3] Encrypting Characters to File:37.04%
[Round-3] Encrypting Characters to File:40.74%
[Round-3] Encrypting Characters to File:44.44%
[Round-3] Encrypting Characters to File:48.15%
[Round-3] Encrypting Characters to File:51.85%
[Round-3] Encrypting Characters to File:55.56%
[Round-3] Encrypting Characters to File:59.26%
[Round-3] Encrypting Characters to File:62.96%
[Round-3] Encrypting Characters to File:66.67%
[Round-3] Encrypting Characters to File:70.37%
[Round-3] Encrypting Characters to File:74.07%
[Round-3] Encrypting Characters to File:77.78%
[Round-3] Encrypting Characters to File:81.48%
[Round-3] Encrypting Characters to File:85.19%
[Round-3] Encrypting Characters to File:88.89%
[Round-3] Encrypting Characters to File:92.59%
[Round-3] Encrypting Characters to File:96.3%
ROUND--4
[Round-4] Encrypting Characters to File:0.0%
[Round-4] Encrypting Characters to File:3.7%
[Round-4] Encrypting Characters to File:7.41%
[Round-4] Encrypting Characters to File:11.11%
[Round-4] Encrypting Characters to File:14.81%
[Round-4] Encrypting Characters to File:18.52%
[Round-4] Encrypting Characters to File:22.22%
[Round-4] Encrypting Characters to File:25.93%
[Round-4] Encrypting Characters to File:29.63%
[Round-4] Encrypting Characters to File:33.33%
[Round-4] Encrypting Characters to File:37.04%
[Round-4] Encrypting Characters to File:40.74%
[Round-4] Encrypting Characters to File:44.44%
[Round-4] Encrypting Characters to File:48.15%
[Round-4] Encrypting Characters to File:51.85%
[Round-4] Encrypting Characters to File:55.56%
[Round-4] Encrypting Characters to File:59.26%
[Round-4] Encrypting Characters to File:62.96%
[Round-4] Encrypting Characters to File:66.67%
[Round-4] Encrypting Characters to File:70.37%
[Round-4] Encrypting Characters to File:74.07%
[Round-4] Encrypting Characters to File:77.78%
[Round-4] Encrypting Characters to File:81.48%
[Round-4] Encrypting Characters to File:85.19%
[Round-4] Encrypting Characters to File:88.89%
[Round-4] Encrypting Characters to File:92.59%
[Round-4] Encrypting Characters to File:96.3%
4 Round Enc/Dec Successfully Completed!

File ENCRYPTED Successfully as 'enc.hades', Stored at'rsa'


ATTENTION! NOW Your Encrypted Private Key
is:6011904659588353984871222574048074509904428233372633331173010531990084661040525218759345460473724282763
8916724924213278901926035304577838462462313229454451345076627377755496410394946385939560263501268932773286
0549220020148009988653089468649981725136561269266515875787187561511484511532661481425875460260979601368988
6905850657996645521180594757560784945444678844883249590603370018993958939537623523189782902792866480579871
2508990971881405209252109477157535923520401041592892669180875012563226478852720343370929541090623678941280
67364035504219129351718647905850502270712795388348241968167291090546022
It is Saved for You at 'rsa/Key-filenameCopy.txt'

Key-filenameCopy.txt
Encrypted Key for File : again.txt Generated on: Sun Apr 14 21:29:17 IST 2019

Note: This is NOT the Secret(private) Key, but Just the RSA Encrypted Cipher text
No Need To keep It a secret:)

6011904659588353984871222574048074509904428233372633331173010531990084661040525218759345460473724282763891672492421
3278901926035304577838462462313229454451345076627377755496410394946385939560263501268932773286054922002014800998865
3089468649981725136561269266515875787187561511484511532661481425875460260979601368988690585065799664552118059475756
0784945444678844883249590603370018993958939537623523189782902792866480579871250899097188140520925210947715753592352
0401041592892669180875012563226478852720343370929541090623678941280673640355042191293517186479058505022707127953883
48241968167291090546022

enc.txt (encrypted text file)


PQAGLKWVQPXTX[BPZ\TG\R`

===============================================================
1.ENCRYPT a file 2.DECRYPT a file 3.Open a File
4.Delete a File 5.Exit Program
===============================================================
Enter Your Choice:
2
Enter Name of the Encrypted File that is to be Decrypted(include path if outside):
C:\codeRepository\crypto\rsa\enc.txt
Enter EXTENSION to which file is to be Decrypted(e.g txt,pdf,jpg,mp3,mp4,etc):
txt
Enter Name of Directory where Decrypted file will be Stored:
rsa
Enter Your Encrypted Private Key of the file:
6011904659588353984871222574048074509904428233372633331173010531990084661040525218759345460473724282763891
6724924213278901926035304577838462462313229454451345076627377755496410394946385939560263501268932773286054
9220020148009988653089468649981725136561269266515875787187561511484511532661481425875460260979601368988690
5850657996645521180594757560784945444678844883249590603370018993958939537623523189782902792866480579871250
8990971881405209252109477157535923520401041592892669180875012563226478852720343370929541090623678941280673
64035504219129351718647905850502270712795388348241968167291090546022
=========================================================================
Enter Mode:
1.FAST(2 Round Enc/Dec) --Estimated Time :: 9.0E-4 seconds (1.5E-5 minutes)
2.FASTER(4-R E/D) --Estimated Time :: 0.0018 seconds (3.0E-5 minutes)
3.STANDARD(8-R E/D) --Estimated Time :: 0.00361 seconds (6.016666666666667E-5 minutes)
4.STANDARD-Plus(12-R E/D) --Estimated Time :: 0.00541 seconds (9.016666666666666E-5 minutes)
5.EXPRESS(16-R E/D) --Estimated Time :: 0.00721 seconds (1.2016666666666667E-4 minutes)
Use Same Mode for Decryption with which the File was ENcrypted!
=========================================================================
2
ROUND--1
[Round-1] Decrypting Characters to File:0.0%
[Round-1] Decrypting Characters to File:3.7%
[Round-1] Decrypting Characters to File:7.41%
[Round-1] Decrypting Characters to File:11.11%
[Round-1] Decrypting Characters to File:14.81%
[Round-1] Decrypting Characters to File:18.52%
[Round-1] Decrypting Characters to File:22.22%
[Round-1] Decrypting Characters to File:25.93%
[Round-1] Decrypting Characters to File:29.63%
[Round-1] Decrypting Characters to File:33.33%
[Round-1] Decrypting Characters to File:37.04%
[Round-1] Decrypting Characters to File:40.74%
[Round-1] Decrypting Characters to File:44.44%
[Round-1] Decrypting Characters to File:48.15%
[Round-1] Decrypting Characters to File:51.85%
[Round-1] Decrypting Characters to File:55.56%
[Round-1] Decrypting Characters to File:59.26%
[Round-1] Decrypting Characters to File:62.96%
[Round-1] Decrypting Characters to File:66.67%
[Round-1] Decrypting Characters to File:70.37%
[Round-1] Decrypting Characters to File:74.07%
[Round-1] Decrypting Characters to File:77.78%
[Round-1] Decrypting Characters to File:81.48%
[Round-1] Decrypting Characters to File:85.19%
[Round-1] Decrypting Characters to File:88.89%
[Round-1] Decrypting Characters to File:92.59%
[Round-1] Decrypting Characters to File:96.3%
ROUND--2
[Round-2] Decrypting Characters to File:0.0%
[Round-2] Decrypting Characters to File:3.7%
[Round-2] Decrypting Characters to File:7.41%
[Round-2] Decrypting Characters to File:11.11%
[Round-2] Decrypting Characters to File:14.81%
[Round-2] Decrypting Characters to File:18.52%
[Round-2] Decrypting Characters to File:22.22%
[Round-2] Decrypting Characters to File:25.93%
[Round-2] Decrypting Characters to File:29.63%
[Round-2] Decrypting Characters to File:33.33%
[Round-2] Decrypting Characters to File:37.04%
[Round-2] Decrypting Characters to File:40.74%
[Round-2] Decrypting Characters to File:44.44%
[Round-2] Decrypting Characters to File:48.15%
[Round-2] Decrypting Characters to File:51.85%
[Round-2] Decrypting Characters to File:55.56%
[Round-2] Decrypting Characters to File:59.26%
[Round-2] Decrypting
Characters to File:62.96%
[Round-2] Decrypting
Characters to File:66.67%
[Round-2] Decrypting
Characters to File:70.37%
[Round-2] Decrypting
Characters to File:74.07%
[Round-2] Decrypting
Characters to File:77.78%
[Round-2] Decrypting
Characters to File:81.48%
[Round-2] Decrypting
Characters to File:85.19%
[Round-2] Decrypting
Characters to File:88.89%
[Round-2] Decrypting
Characters to File:92.59%
[Round-2] Decrypting
Characters to File:96.3%
ROUND--3
[Round-3] Decrypting Characters to File:0.0%
[Round-3] Decrypting Characters to File:3.7%
[Round-3] Decrypting Characters to File:7.41%
[Round-3] Decrypting Characters to File:11.11%
[Round-3] Decrypting Characters to File:14.81%
[Round-3] Decrypting Characters to File:18.52%
[Round-3] Decrypting Characters to File:22.22%
[Round-3] Decrypting Characters to File:25.93%
[Round-3] Decrypting Characters to File:29.63%
[Round-3] Decrypting Characters to File:33.33%
[Round-3] Decrypting Characters to File:37.04%
[Round-3] Decrypting Characters to File:40.74%
[Round-3] Decrypting Characters to File:44.44%
[Round-3] Decrypting Characters to File:48.15%
[Round-3] Decrypting Characters to File:51.85%
[Round-3] Decrypting Characters to File:55.56%
[Round-3] Decrypting Characters to File:59.26%
[Round-3] Decrypting Characters to File:62.96%
[Round-3] Decrypting Characters to File:66.67%
[Round-3] Decrypting Characters to File:70.37%
[Round-3] Decrypting Characters to File:74.07%
[Round-3] Decrypting Characters to File:77.78%
[Round-3] Decrypting Characters to File:81.48%
[Round-3] Decrypting Characters to File:85.19%
[Round-3] Decrypting Characters to File:88.89%
[Round-3] Decrypting Characters to File:92.59%
[Round-3] Decrypting Characters to File:96.3%
ROUND--4
[Round-4] Decrypting Characters to File:0.0%
[Round-4] Decrypting Characters to File:3.7%
[Round-4] Decrypting Characters to File:7.41%
[Round-4] Decrypting Characters to File:11.11%
[Round-4] Decrypting Characters to File:14.81%
[Round-4] Decrypting Characters to File:18.52%
[Round-4] Decrypting Characters to File:22.22%
[Round-4] Decrypting Characters to File:25.93%
[Round-4] Decrypting Characters to File:29.63%
[Round-4] Decrypting Characters to File:33.33%
[Round-4] Decrypting Characters to File:37.04%
[Round-4] Decrypting Characters to File:40.74%
[Round-4] Decrypting Characters to File:44.44%
[Round-4] Decrypting Characters to File:48.15%
[Round-4] Decrypting Characters to File:51.85%
[Round-4] Decrypting Characters to File:55.56%
[Round-4] Decrypting Characters to File:59.26%
[Round-4] Decrypting Characters to File:62.96%
[Round-4] Decrypting Characters to File:66.67%
[Round-4] Decrypting Characters to File:70.37%
[Round-4] Decrypting Characters to File:74.07%
[Round-4] Decrypting Characters to File:77.78%
[Round-4] Decrypting Characters to File:81.48%
[Round-4] Decrypting Characters to File:85.19%
[Round-4] Decrypting Characters to File:88.89%
[Round-4] Decrypting Characters to File:92.59%
[Round-4] Decrypting Characters to File:96.3%
4 Round Enc/Dec Successfully Completed!
Do you want to delete C:/codeRepository/trying/rsa/enc.txt?
Enter 1 for yes and 2 for No:
2

File DECRYPTED Successfully as 'dec.txt,' Stored at 'rsa'

dec.txt(decrypted text file)


This file will be encrypted.

You might also like