Copyright © infotec016 . Powered by Blogger.

Thursday, April 20, 2017

Cryptography : Caesar Cipher


Caesar Cipher

Sample java code for Caesar Cipher

key : each letter shift of two in alphabet order
caesar cipher encryption

eg: hello -----------jgnnq
encryption


import java.util.*;
public class encryption{
public static void main(String args[]){
Scanner myScanner=new Scanner(System.in);
String alpha="abcdefghijklmnopqrstuvwxyz";
String word,text="";
System.out.println("Enter the plain text");
word=myScanner.nextLine().toLowerCase();
System.out.println("cipher text");
for(int i=0;i<word.length();i++){
boolean found=false;
char a=word.charAt(i);
int j=0;
while(j<alpha.length() && !found ){
char b=alpha.charAt(j);
if(a==' '){
text=text+" ";
found=true;
}
else if(a==b ){
found=true;
if(j<24){
text=text+alpha.substring(j+2,j+3);
}
else{
text=text+alpha.substring(j-alpha.length()+2,j-alpha.length()+3);
}
}
j++;
}
}
System.out.print(text);
}
}

output of the above code
   

Cryptography : Vigenere Cipher


Vigenere Cipher

Sample java code for Vigenere Cipher

Encryption

//Vigenere cipher encryption
import java.util.*;
public class vigenere_encry{
public static void main(String args[]){
Scanner myscanner=new Scanner(System.in);
String alpha="abcdefghijklmnopqrstuvwxyz";
String keynew="",cipher="";
System.out.println("Enter the key");
String key=myscanner.nextLine().toLowerCase().replace(" ","");
System.out.println("Enter the plaintext");
String word=myscanner.nextLine().toLowerCase().replace(" ","");
int k=0;
while(k<word.length()/key.length()){
for(int i=0;i<key.length();i++){
keynew=keynew+key.charAt(i);
}
k++;
}

int q=0;
if(word.length()%key.length()!=0){
while(q<word.length()%key.length()){
keynew=keynew+key.charAt(q);
q++;
}
}
System.out.println("key       :"+keynew);
System.out.println("plaintext :"+word);

int numk=0,numw=0;
for(int i=0;i<word.length();i++){
char chark=keynew.charAt(i);
char charw=word.charAt(i);
for(int j=0;j<=25;j++){
if(chark==alpha.charAt(j)){
numk=j;
}
if(charw==alpha.charAt(j)){
numw=j;
}
}
cipher=cipher+alpha.charAt((numk+numw)%26);
}
System.out.println("ciphertext:"+cipher);
}
}



output of the above code

Cryptography : Playfair Cipher


Playfair Cipher

Sample java code for Playfair Cipher


Encryption




//playfair encryption: i and j count as one letter
import java.util.*;
public class playfair_encry{
public static void main(String args[]){
Scanner myscanner=new Scanner(System.in);
System.out.println("Enter the keyword");
String key=myscanner.nextLine().toLowerCase().replace(" ","").replace("j","i");
String alpha="abcdefghiklmnopqrstuvwxyz";
char array[][];
array=new char[5][5];
char arraykey[];
arraykey=new char[key.length()];
arraykey[0]=key.charAt(0);
int m=1;

Cryptography : Railfence Cipher


Railfence Cipher

Sample java code for Railfence Cipher

Key = 2
Encryption


//key=2
import java.util.Scanner;
public class Railfence_encry{
    public static void main(String args[]){
        Scanner myscanner =new Scanner(System.in);
        System.out.println("Enter the plaintext");
        String word=myscanner.nextLine().replace(" ","");
        System.out.println("cipher text");
        
        for(int i=0;i<word.length();i++){
            char a=word.charAt(i);
            if(i%2==0){
                System.out.print(a);
            }
        }
        

Cryptography : Railfence Cipher


Railfence Cipher


Sample java code for Railfence Cipher

Key = 3
Encryption


//key=3
import java.util.*;
public class Railfence1_encry{
    public static void main(String args[]){
        Scanner myscanner =new Scanner(System.in);
        System.out.println("Enter the plaintext");
        String word=myscanner.nextLine().replace(" ","").toLowerCase();
        System.out.println("cipher text");
int i=0;
String text1="",text3="";
while(i<word.length()){
char a=word.charAt(i);
text1=text1+a;
i=i+2;
if(i<word.length()){
a=word.charAt(i);
text3=text3+a;
}
i=i+2;
}
System.out.print(text1);
for(int j=1;j<word.length();j=j+2){
char a=word.charAt(j);
System.out.print(a);
}
System.out.println(text3);
    }
}
     

output of  the above code

Friday, January 6, 2017

Web Hosting


1.Buy a Domain
2.Order a web hosting service
3.Create the website

 Domain Name

Domain Name is the web address of a website.
We will need a domain to create a website.
To get own domain name, we need to register it with a domain register. 
Examples for domain register : 
  • GoDaddy
  • Name Cheap 
  • Domain.com

Monday, December 5, 2016

Challenges that we face in computer security


Computer security is preserving the integrity, availability, and confidentiality of information system resources.

Now,People think that their private accounts and data are safe but still their data may be changed ,theft,or edited by unauthorized people.People should create a secure password and know the all security facilities and implement that facilities.

System developers also develop the systems more securely for users.

People should take attention when they use their private accounts in public computers.

People should backup their important data.