SlideShare a Scribd company logo
1 of 5
[Type here] [Type here] Khushal Choudhary 8606
PRACTICAL NO. 1
Aim: Implementing Substitution Ciphers
a) Caesar Cipher
Code:
// Practical 1 A
import java.util.Scanner;
public class practical1a
{
int total_alphabets=26,key=3;
String encrypted=" ",decrypted=" ";
char ch; public String encrypt
(String plain)
{
for(int i=0;i<plain.length();i++)
{
ch=plain.charAt(i);
if(ch==' ') encrypted+="-";
else if(ch>='A' && ch<='Z')
{
if(ch<='Z'-key)
{
encrypted+=String.valueOf((char)(ch+key));
}
else {
encrypted+=String.valueOf((char)(ch-
(total_alphabetskey)));
}
} else
{
encrypted+=String.valueOf(ch);
}
}
return encrypted;
}
public String decrypt (String cipher)
{
for(int i=0;i<cipher.length();i++)
{
ch=cipher.charAt(i);
if(ch==' ') decrypted+="-";
else if(ch>='A' && ch<='Z')
{
if(ch>='A'+key)
{
[Type here] [Type here] Khushal Choudhary 8606
decrypted+=String.valueOf((char)(ch-key));
}
else {
decrypted+=String.valueOf((char)(ch+(total_alphabetskey)));
}
} else
{
decrypted+=String.valueOf(ch);
}
}
return decrypted;
}
public static void main(String[] args)
{
String plaintext, ciphertext;
practical1a cc= new practical1a();
System.out.println("Enter text");
plaintext=new Scanner(System.in).nextLine().toUpperCase();
ciphertext=cc.encrypt(plaintext);
System.out.println("Encrypted text="+ciphertext);
plaintext=cc.decrypt(ciphertext);
System.out.println("Decrypted text="+plaintext);
} }
Output:
Modified Caesar Cipher
Code:
[Type here] [Type here] Khushal Choudhary 8606
}
} else
{
decrypted+=String.valueOf(ch);
}
}
return decrypted;
}
public static void main(String[] args)
{
String plaintext, ciphertext;
int key; practical1b cc= new
practical1b();
System.out.println("Enter text");
plaintext=new Scanner(System.in).nextLine().toUpperCase();
System.out.println("Enter key "); key=new
Scanner(System.in).nextInt();
ciphertext=cc.encrypt(plaintext,key);
System.out.println("Encrypted text="+ciphertext);
plaintext=cc.decrypt(ciphertext,key);
System.out.println("Decrypted text="+plaintext);
}
}
Output:
Monoalphabetic
[Type here] [Type here] Khushal Choudhary 8606
Code:
}
Output:
d) Poly-Alphabetic
Code:
import java.util.*;
public class Poly
{
public static void main(String[]args)
{
String plaintext="HOWAREYOU";
String secretkey="HELLOHELL";
System.out.println("Plain text before
encryption:"+plaintext);
String encryptedtext=encrypt(plaintext,secretkey);
System.out.println("Encrypted text after
encryption:"+encryptedtext);
String
decryptedtext=decrypt(encryptedtext,secretkey);
System.out.println("Decrypted text after
decryption:"+decryptedtext);
}
private static String encrypt(String plaintext, String
secretkey) {
StringBuffer encryptedString=new
StringBuffer(); int encryptedInt;
for(int i=0;i<plaintext.length();i++)
{ int
plaintextInt=(int)(plaintext.charAt(i));
int secretkeyInt=(int)(secretkey.charAt(i));
encryptedInt=(plaintextInt+secretkeyInt)%26;
encryptedString.append((char)((encryptedInt)+(int)'A'));
}
return encryptedString.toString();
}
private static String decrypt(String decryptedtext, String
secretkey) {
[Type here] [Type here] Khushal Choudhary 8606
StringBuffer decryptedString=new
StringBuffer(); int decryptedInt;
for(int i=0;i<decryptedtext.length();i++)
{
int
decryptedtextInt=(int)(decryptedtext.charAt(i));
int secretkeyInt=(int)(secretkey.charAt(i));
decryptedInt=decryptedtextInt-secretkeyInt;
if(decryptedInt<0)
Output:

More Related Content

Similar to 8606 ins prac 1.docx

import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfshettysachin2005
 
#include String.hpp#include ..Functionsfunctions.hpp.docx
#include String.hpp#include ..Functionsfunctions.hpp.docx#include String.hpp#include ..Functionsfunctions.hpp.docx
#include String.hpp#include ..Functionsfunctions.hpp.docxgertrudebellgrove
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
Data structure
Data structureData structure
Data structureMarkustec
 
Module-2_Strings concepts in c programming
Module-2_Strings concepts in c programmingModule-2_Strings concepts in c programming
Module-2_Strings concepts in c programmingCHAITRAB29
 
Programing with java for begniers .pptx
Programing with java for begniers  .pptxPrograming with java for begniers  .pptx
Programing with java for begniers .pptxadityaraj7711
 
#include stdio.h #include stdlib.h #include unistd.h #in.pdf
#include stdio.h #include stdlib.h #include unistd.h #in.pdf#include stdio.h #include stdlib.h #include unistd.h #in.pdf
#include stdio.h #include stdlib.h #include unistd.h #in.pdfcontact34
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1kkkseld
 
Add a 3rd field help that contains a short help string for each of t.pdf
Add a 3rd field help that contains a short help string for each of t.pdfAdd a 3rd field help that contains a short help string for each of t.pdf
Add a 3rd field help that contains a short help string for each of t.pdfinfo245627
 
Help with this substitution program- line 3 of the output is different.pdf
Help with this substitution program- line 3 of the output is different.pdfHelp with this substitution program- line 3 of the output is different.pdf
Help with this substitution program- line 3 of the output is different.pdfgaurav444u
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)teach4uin
 
talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013ericupnorth
 

Similar to 8606 ins prac 1.docx (15)

import java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdfimport java.util.ArrayList; import java.util.Scanner;public clas.pdf
import java.util.ArrayList; import java.util.Scanner;public clas.pdf
 
#include String.hpp#include ..Functionsfunctions.hpp.docx
#include String.hpp#include ..Functionsfunctions.hpp.docx#include String.hpp#include ..Functionsfunctions.hpp.docx
#include String.hpp#include ..Functionsfunctions.hpp.docx
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Data structure
Data structureData structure
Data structure
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Module-2_Strings concepts in c programming
Module-2_Strings concepts in c programmingModule-2_Strings concepts in c programming
Module-2_Strings concepts in c programming
 
Programing with java for begniers .pptx
Programing with java for begniers  .pptxPrograming with java for begniers  .pptx
Programing with java for begniers .pptx
 
#include stdio.h #include stdlib.h #include unistd.h #in.pdf
#include stdio.h #include stdlib.h #include unistd.h #in.pdf#include stdio.h #include stdlib.h #include unistd.h #in.pdf
#include stdio.h #include stdlib.h #include unistd.h #in.pdf
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
C programms
C programmsC programms
C programms
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Add a 3rd field help that contains a short help string for each of t.pdf
Add a 3rd field help that contains a short help string for each of t.pdfAdd a 3rd field help that contains a short help string for each of t.pdf
Add a 3rd field help that contains a short help string for each of t.pdf
 
Help with this substitution program- line 3 of the output is different.pdf
Help with this substitution program- line 3 of the output is different.pdfHelp with this substitution program- line 3 of the output is different.pdf
Help with this substitution program- line 3 of the output is different.pdf
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
 
talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013talk at Virginia Bioinformatics Institute, December 5, 2013
talk at Virginia Bioinformatics Institute, December 5, 2013
 

Recently uploaded

BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramMoniSankarHazra
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Pooja Nehwal
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...amitlee9823
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...amitlee9823
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...amitlee9823
 

Recently uploaded (20)

BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Capstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics ProgramCapstone Project on IBM Data Analytics Program
Capstone Project on IBM Data Analytics Program
 
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
(NEHA) Call Girls Katra Call Now 8617697112 Katra Escorts 24x7
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 

8606 ins prac 1.docx

  • 1. [Type here] [Type here] Khushal Choudhary 8606 PRACTICAL NO. 1 Aim: Implementing Substitution Ciphers a) Caesar Cipher Code: // Practical 1 A import java.util.Scanner; public class practical1a { int total_alphabets=26,key=3; String encrypted=" ",decrypted=" "; char ch; public String encrypt (String plain) { for(int i=0;i<plain.length();i++) { ch=plain.charAt(i); if(ch==' ') encrypted+="-"; else if(ch>='A' && ch<='Z') { if(ch<='Z'-key) { encrypted+=String.valueOf((char)(ch+key)); } else { encrypted+=String.valueOf((char)(ch- (total_alphabetskey))); } } else { encrypted+=String.valueOf(ch); } } return encrypted; } public String decrypt (String cipher) { for(int i=0;i<cipher.length();i++) { ch=cipher.charAt(i); if(ch==' ') decrypted+="-"; else if(ch>='A' && ch<='Z') { if(ch>='A'+key) {
  • 2. [Type here] [Type here] Khushal Choudhary 8606 decrypted+=String.valueOf((char)(ch-key)); } else { decrypted+=String.valueOf((char)(ch+(total_alphabetskey))); } } else { decrypted+=String.valueOf(ch); } } return decrypted; } public static void main(String[] args) { String plaintext, ciphertext; practical1a cc= new practical1a(); System.out.println("Enter text"); plaintext=new Scanner(System.in).nextLine().toUpperCase(); ciphertext=cc.encrypt(plaintext); System.out.println("Encrypted text="+ciphertext); plaintext=cc.decrypt(ciphertext); System.out.println("Decrypted text="+plaintext); } } Output: Modified Caesar Cipher Code:
  • 3. [Type here] [Type here] Khushal Choudhary 8606 } } else { decrypted+=String.valueOf(ch); } } return decrypted; } public static void main(String[] args) { String plaintext, ciphertext; int key; practical1b cc= new practical1b(); System.out.println("Enter text"); plaintext=new Scanner(System.in).nextLine().toUpperCase(); System.out.println("Enter key "); key=new Scanner(System.in).nextInt(); ciphertext=cc.encrypt(plaintext,key); System.out.println("Encrypted text="+ciphertext); plaintext=cc.decrypt(ciphertext,key); System.out.println("Decrypted text="+plaintext); } } Output: Monoalphabetic
  • 4. [Type here] [Type here] Khushal Choudhary 8606 Code: } Output: d) Poly-Alphabetic Code: import java.util.*; public class Poly { public static void main(String[]args) { String plaintext="HOWAREYOU"; String secretkey="HELLOHELL"; System.out.println("Plain text before encryption:"+plaintext); String encryptedtext=encrypt(plaintext,secretkey); System.out.println("Encrypted text after encryption:"+encryptedtext); String decryptedtext=decrypt(encryptedtext,secretkey); System.out.println("Decrypted text after decryption:"+decryptedtext); } private static String encrypt(String plaintext, String secretkey) { StringBuffer encryptedString=new StringBuffer(); int encryptedInt; for(int i=0;i<plaintext.length();i++) { int plaintextInt=(int)(plaintext.charAt(i)); int secretkeyInt=(int)(secretkey.charAt(i)); encryptedInt=(plaintextInt+secretkeyInt)%26; encryptedString.append((char)((encryptedInt)+(int)'A')); } return encryptedString.toString(); } private static String decrypt(String decryptedtext, String secretkey) {
  • 5. [Type here] [Type here] Khushal Choudhary 8606 StringBuffer decryptedString=new StringBuffer(); int decryptedInt; for(int i=0;i<decryptedtext.length();i++) { int decryptedtextInt=(int)(decryptedtext.charAt(i)); int secretkeyInt=(int)(secretkey.charAt(i)); decryptedInt=decryptedtextInt-secretkeyInt; if(decryptedInt<0) Output: