An easy Caesar Cipher ISC Practical 2017 Program 3
Write a program to accept a plain text of length L, where L must be greater than 3 and less than 100. Encrypt the text if valid as per the Caesar Cipher. Test your program with the sample data and some random data: Example 1 INPUT : Hello! How are you?OUTPUT: Uryyb? Ubj ner lbh? Example
Caesar Cipher is an encryption technique that is implemented as ROT13. It is a simple letter substitution cipher that replaces a letter with the letter 13 places after it in the alphabets, with the other characters remaining unchanged.
Watch Java videos

Write a program to accept a plain text of length L, where L must be greater than 3 and less than 100. Encrypt the text if valid as per the Caesar Cipher. Test your program with the sample data and some random data:
Example 1
INPUT : Hello! How are you?
OUTPUT:
Uryyb? Ubj ner lbh?
Example 2
INPUT : Encryption helps to secure data.
OUTPUT : Rapelcgvba urycf gb frpher qngn.
Example 3
INPUT : You
OUTPUT : INVALID LENGTH
import java.io.*;
public class caeser_cipher
{
String str,str2="";
int len;
void input()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the string");
str=br.readLine();
len=str.length();
}
void compute()
{
char ch,ch2;
int l,m;
for(int i=0;i<len;i++)
{
ch=str.charAt(i);
if(Character.isLetter(ch)==true)
{l=(int)ch;
if(l==97||l<=109||l==65||(l<=77&&l<90))
{
m=l+13;
ch2=(char)m;
str2+=ch2;
}
else
{
m=l-13;
ch2=(char)m;
str2+=ch2;
}
}
else
str2+=ch;
}
}
void display()
{
System.out.println("the original string was:"+str);
System.out.println("the cipher string is:"+str2);
}
public static void main()throws IOException
{
caeser_cipher obj=new caeser_cipher();
obj.input();
obj.compute();
obj.display();
}
}Pronic Number
Related Posts
Continue learning with these related articles

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.

Boolean Algebra for ISC Class 12: Laws, Canonical SOP and POS, and Simplification
ISC Class 12 Computer Science notes on Boolean algebra: all the laws and theorems, duality, De Morgan's laws, minterms and maxterms, converting to canonical SOP and POS, and step-by-step algebraic simplification with solved examples.