









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Caesar Cipher program in java (SS) In cryptography Caesar cipher is one of the simple and most widely used Encryption algorithm.Caesar cipher is special case of shift cipher.Caesar cipher is substitution cipher where letter in plain text is replaced by some other letter.If shift is 3 then A letter is replaced by D,B is replaced by E and so on. import java.io.; import java.lang.; class Caesar Cipher { public static void main(String args[])throws IOException { String plaintext; int n; int z; int ascii ; DataInputStream in=new DataInputStream(System.in); System.out.print("\nEnter plain text\t"); plaintext=in.readLine(); char ptext[]=plaintext.toCharArray(); n=plaintext.length(); char Caesar_Cipher[]=new char[n]; System.out.print("\n\nEnter Caesar Cipher shift key\t\t"); z=Integer.parseInt(in.readLine());
for(int i=0;i<n;i++) { ascii = (int)ptext[i]; ascii=ascii-97; ascii =((ascii+z)%26); ascii=ascii+97; Caesar_Cipher[i]=(char)ascii; } System.out.print("\n\nCaesar Cipher text:\t\t"); for(int i=0;i<n;i++) { System.out.print(Caesar_Cipher[i]); } } } /* Caesar Cipher program output: Enter plain text : cipher program Enter Caesar Cipher shift key : 2 Caesar Cipher text: : ekrjgtVrtqitco
try{ ps=new PrintStream("log.txt"); }catch(Exception e) {e.printStackTrace();} } public void read() { System.out.println("Enter the filename"); filename=sc.next(); } public void compute() { for(int i=0;i<database.length;i++) { if(filename.contains(database[i][1])) { virus=database[i][0]; found=true; break; } } } public void addToLog()
int count=0,i=0; if(found) { try { Date d=new Date(); ps.println(virus+" virus found in file "+filename+" on "+d); } catch(Exception e) { e.printStackTrace(); } } } public void display() { if(found) System.out.println("\nFile is infected with "+virus+" virus"); else System.out.println("File is virus free"); } public static void main(String args[])
RSA algorithm program in java (SS) RSA is a public key encryption algorithm and the name RSA derived from it's investors Rivest,Shamir,Adleman.RSA works on the principle that says it is too difficult to find the factor of large prime numbers. import java.io.; import java.math.; class rsa { public static void main(String args[])throws IOException { int q,p,n,pn,publickey=0,d=0,msg;
double cipher,ptext; int check,check1; DataInputStream in=new DataInputStream(System.in); System.out.println("ENTER NO"); p=Integer.parseInt(in.readLine()); q=Integer.parseInt(in.readLine()); check=prime(p); check1=prime(q); if(check!=1||check1!=1) { System.exit(0); } n=pq; pn=(p-1)(q-1); for(int e=2;e<pn;e++) { if(gcd(e,pn)==1) { publickey=e; System.out.println("PUBLIC KEY :"+e); break; } } for(int i=0;i<pn;i++) { d=i; if(((d*publickey)%pn)==1) break; } System.out.println("PRIVATE KEY :"+d); System.out.println("ENTER MESSAGE "); msg=Integer.parseInt(in.readLine()); cipher=Math.pow(msg,publickey); cipher=cipher%n; System.out.println("ENCRYPTED :"+cipher);
RC4 encryption algorithm program in java(SS) In cryptography is most widely used software stream cipher and is used popular protocols such as secure socket layer(SSL) and wep. RC4 has variable length key. RC4 is developed by Ronald Rivest which require secure exchange of shared key..RC4 algorithm operates in OFB (output feedback mode) ,where block cipher is implemented as stream cipher.RC4 generates pseudo-random stream of bits.In RC4 algorithm key stream is completely independent of plain text. import java.io.*; class rc 4 { public static void main(String args[])throws IOException { int temp=0; String ptext; String key; int s[]=new int[256]; int k[]=new int[256]; DataInputStream in=new DataInputStream(System.in); System.out.print("\nENTER PLAIN TEXT\t"); ptext=in.readLine(); System.out.print("\n\nENTER KEY TEXT\t\t"); key=in.readLine(); char ptextc[]=ptext.toCharArray(); char keyc[]=key.toCharArray(); int cipher[]=new int[ptext.length()]; int decrypt[]=new int[ptext.length()]; int ptexti[]=new int[ptext.length()];
System.out.print("\n\nENCRYPTED:\t\t"); display(cipher); System.out.print("\n\nDECRYPTED:\t\t"); display(decrypt); } static void display(int disp[]) { char convert[]=new char[disp.length]; for(int l=0;l<disp.length;l++) { convert[l]=(char)disp[l]; System.out.print(convert[l]); } } } /* RC4 encryption algorithm Program Output : ENTER PLAIN TEXT RC4 PROGRAM ENTER KEY TEXT A ENCRYPTED: ??-??±?μFJ| DECRYPTED: RC4 PROGRAM */
CAPTCHA program in java applet SS system security CAPTCHA is challenge response test most often placed within form to determine that the user is a human being and not a machine. CAPTCHA is a form of access control.A CAPTCHA images shows a random string which user has to type to submit a form. CAPTCHA generates and grades the test that human can pass but current computer program cannot.since computers are assumed to be unable to solve CAPTCHA,any user entering a correct format is presumed to be human. CAPTCHA are mainly used by websites that offers services like online polls and registration forms. How TO Run
public void paint(Graphics g) { g.drawImage(img1, 10,10,this); g.drawString(msg,100,300); } } OUTPUT: