SlideShare une entreprise Scribd logo
1  sur  4
Programming Language: C++ or Java
Write to program to generate a pair of private and public keys. You program should also be able
to encrypt and decrypt messages using the public and private keys.
Solution
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.scrRndm;
import java.security.Security;
import sun.misc.BASE64Encoder;
public class gnrateKys{
public static void main(String[] args)
{
String PBLCkEY = null;
String PRVATEkEYfM = null;
gnrateKys gnrateKys = new gnrateKys();
if (args.length < 2)
{
System.err.println(gnrateKys.getClass().getName());
System.exit(1);
}
PBLCkEY = args[0].trim();
PRVATEkEYfM = args[1].trim();
gnrateKys.generate(PBLCkEY, PRVATEkEYfM);
}
private void generate (String PBLCkEY, String privateFilename){
try {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
KeyPairGenerator gnrtr = KeyPairGenerator.getInstance("RSA", "BC");
BASE64Encoder b64Enc = new BASE64Encoder();
scrRndm random = createFixedRandom();
gnrtr.initialize(1024, random);
KeyPair par = gnrtr.generateKeyPair();
Key pbkey = par.getPublic();
Key prvKy = par.getPrivate();
System.out.println("publicKey : " + b64Enc.encode(pbkey.getEncoded()));
System.out.println("privateKey : " + b64Enc.encode(prvKy.getEncoded()));
BufferedWriter out = new BufferedWriter(new FileWriter(PBLCkEY));
out.write(b64Enc.encode(pbkey.getEncoded()));
out.close();
out = new BufferedWriter(new FileWriter(privateFilename));
out.write(b64Enc.encode(prvKy.getEncoded()));
out.close();
}
catch (Exception e) {
System.out.println(e);
}
}
public static scrRndm createFixedRandom()
{
return new FixedRand();
}
private static class FixedRand extends scrRndm {
MessageDigest sha;
byte[] state;
FixedRand() {
try
{
this.sha = MessageDigest.getInstance("SHA-1");
this.state = sha.digest();
}
catch (NoSuchAlgorithmException e)
{
throw new RuntimeException("can't find SHA-1!");
}
}
public void nextBytes(byte[] bytes){
int off = 0;
sha.update(state);
while (off < bytes.length)
{
state = sha.digest();
if (bytes.length - off > state.length)
{
System.arraycopy(state, 0, bytes, off, state.length);
}
else
{
System.arraycopy(state, 0, bytes, off, bytes.length - off);
}
off += state.length;
sha.update(state);
}
}
}
}
Programming Language- C++ or Java Write to program to generate a pair.docx

Contenu connexe

Similaire à Programming Language- C++ or Java Write to program to generate a pair.docx

CogLab Information.htmlCogLab InformationCogLabs for this
CogLab Information.htmlCogLab InformationCogLabs for this CogLab Information.htmlCogLab InformationCogLabs for this
CogLab Information.htmlCogLab InformationCogLabs for this WilheminaRossi174
 
July 2015 Android Taipei - Anti-Decompiler by SUKI
July 2015 Android Taipei - Anti-Decompiler by SUKIJuly 2015 Android Taipei - Anti-Decompiler by SUKI
July 2015 Android Taipei - Anti-Decompiler by SUKISuki Huang
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
Hibernate Import.Sql I18n
Hibernate Import.Sql I18nHibernate Import.Sql I18n
Hibernate Import.Sql I18nyifi2009
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneDroidConTLV
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software DevelopmentZeeshan MIrza
 
Top 20 java programming interview questions for sdet
Top 20 java programming interview questions for sdetTop 20 java programming interview questions for sdet
Top 20 java programming interview questions for sdetDevLabs Alliance
 
Parallelogram by using j2 me j2me.shahid
Parallelogram by using j2 me j2me.shahidParallelogram by using j2 me j2me.shahid
Parallelogram by using j2 me j2me.shahidShahid Riaz
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacksKapil Nagrale
 
Implement symmetric key algorithms.pptx
Implement symmetric key algorithms.pptxImplement symmetric key algorithms.pptx
Implement symmetric key algorithms.pptxpreethihp4500
 
What the Struts?
What the Struts?What the Struts?
What the Struts?Joe Kutner
 
Create & Execute First Hadoop MapReduce Project in.pptx
Create & Execute First Hadoop MapReduce Project in.pptxCreate & Execute First Hadoop MapReduce Project in.pptx
Create & Execute First Hadoop MapReduce Project in.pptxvishal choudhary
 
java object oriented presentation
java object oriented presentationjava object oriented presentation
java object oriented presentationAli Ahsan Mujahid
 
import com.rogue.roguer.command.CommandHandler; import com.rogue.r.pdf
import com.rogue.roguer.command.CommandHandler; import com.rogue.r.pdfimport com.rogue.roguer.command.CommandHandler; import com.rogue.r.pdf
import com.rogue.roguer.command.CommandHandler; import com.rogue.r.pdfDEEPAKSONI562
 
Java Programs Lab File
Java Programs Lab FileJava Programs Lab File
Java Programs Lab FileKandarp Tiwari
 

Similaire à Programming Language- C++ or Java Write to program to generate a pair.docx (20)

Java day 2016.pptx
Java day 2016.pptxJava day 2016.pptx
Java day 2016.pptx
 
CogLab Information.htmlCogLab InformationCogLabs for this
CogLab Information.htmlCogLab InformationCogLabs for this CogLab Information.htmlCogLab InformationCogLabs for this
CogLab Information.htmlCogLab InformationCogLabs for this
 
Cursor Demo App
Cursor Demo AppCursor Demo App
Cursor Demo App
 
Java
JavaJava
Java
 
July 2015 Android Taipei - Anti-Decompiler by SUKI
July 2015 Android Taipei - Anti-Decompiler by SUKIJuly 2015 Android Taipei - Anti-Decompiler by SUKI
July 2015 Android Taipei - Anti-Decompiler by SUKI
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
Hibernate Import.Sql I18n
Hibernate Import.Sql I18nHibernate Import.Sql I18n
Hibernate Import.Sql I18n
 
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGeneBang-Bang, you have been hacked - Yonatan Levin, KolGene
Bang-Bang, you have been hacked - Yonatan Levin, KolGene
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
Top 20 java programming interview questions for sdet
Top 20 java programming interview questions for sdetTop 20 java programming interview questions for sdet
Top 20 java programming interview questions for sdet
 
Parallelogram by using j2 me j2me.shahid
Parallelogram by using j2 me j2me.shahidParallelogram by using j2 me j2me.shahid
Parallelogram by using j2 me j2me.shahid
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
Core Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug HuntCore Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug Hunt
 
Implement symmetric key algorithms.pptx
Implement symmetric key algorithms.pptxImplement symmetric key algorithms.pptx
Implement symmetric key algorithms.pptx
 
What the Struts?
What the Struts?What the Struts?
What the Struts?
 
Create & Execute First Hadoop MapReduce Project in.pptx
Create & Execute First Hadoop MapReduce Project in.pptxCreate & Execute First Hadoop MapReduce Project in.pptx
Create & Execute First Hadoop MapReduce Project in.pptx
 
java object oriented presentation
java object oriented presentationjava object oriented presentation
java object oriented presentation
 
import com.rogue.roguer.command.CommandHandler; import com.rogue.r.pdf
import com.rogue.roguer.command.CommandHandler; import com.rogue.r.pdfimport com.rogue.roguer.command.CommandHandler; import com.rogue.r.pdf
import com.rogue.roguer.command.CommandHandler; import com.rogue.r.pdf
 
Java Programs Lab File
Java Programs Lab FileJava Programs Lab File
Java Programs Lab File
 

Plus de todd921

Question 1 2 points Save Team building is designed to gather.docx
Question 1  2  points    Save    Team  building is designed to gather.docxQuestion 1  2  points    Save    Team  building is designed to gather.docx
Question 1 2 points Save Team building is designed to gather.docxtodd921
 
Question 21 2 points Save How do training and development with.docx
Question  21  2 points   Save    How do training and development with.docxQuestion  21  2 points   Save    How do training and development with.docx
Question 21 2 points Save How do training and development with.docxtodd921
 
QS# 2- 9-17 What is the difference between a note payable and an accou.docx
QS# 2- 9-17 What is the difference between a note payable and an accou.docxQS# 2- 9-17 What is the difference between a note payable and an accou.docx
QS# 2- 9-17 What is the difference between a note payable and an accou.docxtodd921
 
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docxQ1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docxtodd921
 
Q- Lord Rutherford found that most of an atom consists of empty space-.docx
Q- Lord Rutherford found that most of an atom consists of empty space-.docxQ- Lord Rutherford found that most of an atom consists of empty space-.docx
Q- Lord Rutherford found that most of an atom consists of empty space-.docxtodd921
 
PYTHON Programming Language Design a class named Account that contains.docx
PYTHON Programming Language Design a class named Account that contains.docxPYTHON Programming Language Design a class named Account that contains.docx
PYTHON Programming Language Design a class named Account that contains.docxtodd921
 
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docx
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docxPurchases Date Units Unit Cost Sales Units Average cost for each unit.docx
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docxtodd921
 
Provide examples of applications that typically access files according.docx
Provide examples of applications that typically access files according.docxProvide examples of applications that typically access files according.docx
Provide examples of applications that typically access files according.docxtodd921
 
Provide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxProvide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxtodd921
 
Provide a summary of the basic ideals and significant individuals behi.docx
Provide a summary of the basic ideals and significant individuals behi.docxProvide a summary of the basic ideals and significant individuals behi.docx
Provide a summary of the basic ideals and significant individuals behi.docxtodd921
 
proposed solution to resource sharing and security against unauthorize.docx
proposed solution to resource sharing and security against unauthorize.docxproposed solution to resource sharing and security against unauthorize.docx
proposed solution to resource sharing and security against unauthorize.docxtodd921
 
Question 30 As people become more powerful they tend to become less go.docx
Question 30 As people become more powerful they tend to become less go.docxQuestion 30 As people become more powerful they tend to become less go.docx
Question 30 As people become more powerful they tend to become less go.docxtodd921
 
Question 34 People with high Machiavellian values tend to- place a lot.docx
Question 34 People with high Machiavellian values tend to- place a lot.docxQuestion 34 People with high Machiavellian values tend to- place a lot.docx
Question 34 People with high Machiavellian values tend to- place a lot.docxtodd921
 
Question 21 Resource scarcity is a likely cause of conflict in organiz.docx
Question 21 Resource scarcity is a likely cause of conflict in organiz.docxQuestion 21 Resource scarcity is a likely cause of conflict in organiz.docx
Question 21 Resource scarcity is a likely cause of conflict in organiz.docxtodd921
 
Question 2 Compare the eye to a camera by listing four of the basic co.docx
Question 2 Compare the eye to a camera by listing four of the basic co.docxQuestion 2 Compare the eye to a camera by listing four of the basic co.docx
Question 2 Compare the eye to a camera by listing four of the basic co.docxtodd921
 
Question 1- The alien species has decided that they will use a special.docx
Question 1- The alien species has decided that they will use a special.docxQuestion 1- The alien species has decided that they will use a special.docx
Question 1- The alien species has decided that they will use a special.docxtodd921
 
Question 13 Which of the following is the first stage of an experienti.docx
Question 13 Which of the following is the first stage of an experienti.docxQuestion 13 Which of the following is the first stage of an experienti.docx
Question 13 Which of the following is the first stage of an experienti.docxtodd921
 
Question 11 Active communication occurs by facial expressions- body po.docx
Question 11 Active communication occurs by facial expressions- body po.docxQuestion 11 Active communication occurs by facial expressions- body po.docx
Question 11 Active communication occurs by facial expressions- body po.docxtodd921
 
QUESTION 1 Interaction Design is designing interactive products to sup.docx
QUESTION 1 Interaction Design is designing interactive products to sup.docxQUESTION 1 Interaction Design is designing interactive products to sup.docx
QUESTION 1 Interaction Design is designing interactive products to sup.docxtodd921
 
question 1 What is the behavior of setting C locale- Strings are alway.docx
question 1 What is the behavior of setting C locale- Strings are alway.docxquestion 1 What is the behavior of setting C locale- Strings are alway.docx
question 1 What is the behavior of setting C locale- Strings are alway.docxtodd921
 

Plus de todd921 (20)

Question 1 2 points Save Team building is designed to gather.docx
Question 1  2  points    Save    Team  building is designed to gather.docxQuestion 1  2  points    Save    Team  building is designed to gather.docx
Question 1 2 points Save Team building is designed to gather.docx
 
Question 21 2 points Save How do training and development with.docx
Question  21  2 points   Save    How do training and development with.docxQuestion  21  2 points   Save    How do training and development with.docx
Question 21 2 points Save How do training and development with.docx
 
QS# 2- 9-17 What is the difference between a note payable and an accou.docx
QS# 2- 9-17 What is the difference between a note payable and an accou.docxQS# 2- 9-17 What is the difference between a note payable and an accou.docx
QS# 2- 9-17 What is the difference between a note payable and an accou.docx
 
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docxQ1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
Q1) Prepare the year end closing entries for eagles corp- Q2) what is.docx
 
Q- Lord Rutherford found that most of an atom consists of empty space-.docx
Q- Lord Rutherford found that most of an atom consists of empty space-.docxQ- Lord Rutherford found that most of an atom consists of empty space-.docx
Q- Lord Rutherford found that most of an atom consists of empty space-.docx
 
PYTHON Programming Language Design a class named Account that contains.docx
PYTHON Programming Language Design a class named Account that contains.docxPYTHON Programming Language Design a class named Account that contains.docx
PYTHON Programming Language Design a class named Account that contains.docx
 
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docx
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docxPurchases Date Units Unit Cost Sales Units Average cost for each unit.docx
Purchases Date Units Unit Cost Sales Units Average cost for each unit.docx
 
Provide examples of applications that typically access files according.docx
Provide examples of applications that typically access files according.docxProvide examples of applications that typically access files according.docx
Provide examples of applications that typically access files according.docx
 
Provide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docxProvide copy constructor- destructor- and assignment operator for the.docx
Provide copy constructor- destructor- and assignment operator for the.docx
 
Provide a summary of the basic ideals and significant individuals behi.docx
Provide a summary of the basic ideals and significant individuals behi.docxProvide a summary of the basic ideals and significant individuals behi.docx
Provide a summary of the basic ideals and significant individuals behi.docx
 
proposed solution to resource sharing and security against unauthorize.docx
proposed solution to resource sharing and security against unauthorize.docxproposed solution to resource sharing and security against unauthorize.docx
proposed solution to resource sharing and security against unauthorize.docx
 
Question 30 As people become more powerful they tend to become less go.docx
Question 30 As people become more powerful they tend to become less go.docxQuestion 30 As people become more powerful they tend to become less go.docx
Question 30 As people become more powerful they tend to become less go.docx
 
Question 34 People with high Machiavellian values tend to- place a lot.docx
Question 34 People with high Machiavellian values tend to- place a lot.docxQuestion 34 People with high Machiavellian values tend to- place a lot.docx
Question 34 People with high Machiavellian values tend to- place a lot.docx
 
Question 21 Resource scarcity is a likely cause of conflict in organiz.docx
Question 21 Resource scarcity is a likely cause of conflict in organiz.docxQuestion 21 Resource scarcity is a likely cause of conflict in organiz.docx
Question 21 Resource scarcity is a likely cause of conflict in organiz.docx
 
Question 2 Compare the eye to a camera by listing four of the basic co.docx
Question 2 Compare the eye to a camera by listing four of the basic co.docxQuestion 2 Compare the eye to a camera by listing four of the basic co.docx
Question 2 Compare the eye to a camera by listing four of the basic co.docx
 
Question 1- The alien species has decided that they will use a special.docx
Question 1- The alien species has decided that they will use a special.docxQuestion 1- The alien species has decided that they will use a special.docx
Question 1- The alien species has decided that they will use a special.docx
 
Question 13 Which of the following is the first stage of an experienti.docx
Question 13 Which of the following is the first stage of an experienti.docxQuestion 13 Which of the following is the first stage of an experienti.docx
Question 13 Which of the following is the first stage of an experienti.docx
 
Question 11 Active communication occurs by facial expressions- body po.docx
Question 11 Active communication occurs by facial expressions- body po.docxQuestion 11 Active communication occurs by facial expressions- body po.docx
Question 11 Active communication occurs by facial expressions- body po.docx
 
QUESTION 1 Interaction Design is designing interactive products to sup.docx
QUESTION 1 Interaction Design is designing interactive products to sup.docxQUESTION 1 Interaction Design is designing interactive products to sup.docx
QUESTION 1 Interaction Design is designing interactive products to sup.docx
 
question 1 What is the behavior of setting C locale- Strings are alway.docx
question 1 What is the behavior of setting C locale- Strings are alway.docxquestion 1 What is the behavior of setting C locale- Strings are alway.docx
question 1 What is the behavior of setting C locale- Strings are alway.docx
 

Dernier

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 

Dernier (20)

4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 

Programming Language- C++ or Java Write to program to generate a pair.docx

  • 1. Programming Language: C++ or Java Write to program to generate a pair of private and public keys. You program should also be able to encrypt and decrypt messages using the public and private keys. Solution import java.io.BufferedWriter; import java.io.FileWriter; import java.security.Key; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.scrRndm; import java.security.Security; import sun.misc.BASE64Encoder; public class gnrateKys{ public static void main(String[] args) { String PBLCkEY = null; String PRVATEkEYfM = null; gnrateKys gnrateKys = new gnrateKys(); if (args.length < 2) { System.err.println(gnrateKys.getClass().getName()); System.exit(1); }
  • 2. PBLCkEY = args[0].trim(); PRVATEkEYfM = args[1].trim(); gnrateKys.generate(PBLCkEY, PRVATEkEYfM); } private void generate (String PBLCkEY, String privateFilename){ try { Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); KeyPairGenerator gnrtr = KeyPairGenerator.getInstance("RSA", "BC"); BASE64Encoder b64Enc = new BASE64Encoder(); scrRndm random = createFixedRandom(); gnrtr.initialize(1024, random); KeyPair par = gnrtr.generateKeyPair(); Key pbkey = par.getPublic(); Key prvKy = par.getPrivate(); System.out.println("publicKey : " + b64Enc.encode(pbkey.getEncoded())); System.out.println("privateKey : " + b64Enc.encode(prvKy.getEncoded())); BufferedWriter out = new BufferedWriter(new FileWriter(PBLCkEY)); out.write(b64Enc.encode(pbkey.getEncoded())); out.close(); out = new BufferedWriter(new FileWriter(privateFilename)); out.write(b64Enc.encode(prvKy.getEncoded())); out.close(); } catch (Exception e) { System.out.println(e); } } public static scrRndm createFixedRandom() { return new FixedRand(); }
  • 3. private static class FixedRand extends scrRndm { MessageDigest sha; byte[] state; FixedRand() { try { this.sha = MessageDigest.getInstance("SHA-1"); this.state = sha.digest(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("can't find SHA-1!"); } } public void nextBytes(byte[] bytes){ int off = 0; sha.update(state); while (off < bytes.length) { state = sha.digest(); if (bytes.length - off > state.length) { System.arraycopy(state, 0, bytes, off, state.length); } else { System.arraycopy(state, 0, bytes, off, bytes.length - off); } off += state.length; sha.update(state); } } } }