/* * To change this template, choose Tools | Templates * and open the template in the editor. */package test;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.math.BigInteger;/** * * */public class ElgamaED { MyElGamal pkc = new MyElGamal(); MyTransformer trfmr; public byte encrypt(String fpath,String owner) throws IOException { trfmr = pkc.getEncrypter(); File inFile = new File(fpath); int inputLength = (int)(inFile.length()/100 + 1)*100; BufferedInputStream inStrm = new BufferedInputStream( new FileInputStream(inFile)); BufferedOutputStream outStrm = new BufferedOutputStream( new FileOutputStream(“D:”+owner+”.out”)); System.err.println(“Buffer size = ” + inputLength); byte buf = new byteinputLength; System.out.println(“^^^^^^=====”+new String(buf)); int nBytes = inStrm.read(buf); System.out.println(“” + nBytes + ” bytes read”); byte msg = new bytenBytes; System.arraycopy(buf, 0, msg, 0, nBytes); System.out.println(“=====”+new String(msg)); byte tmsg = trfmr.transform(msg); System.out.println(“” + tmsg.length + ” bytes produced”); System.out.println(“encrypte message” +new String(tmsg) ); outStrm.write(tmsg); inStrm.close(); outStrm.close(); return tmsg; } public String decrypt(String fname,String owner) throws IOException { trfmr = pkc.getDecrypter(); File inFile = new File(“D:”+owner+”.out”); int inputLength = (int)(inFile.length()/100 + 1)*100; BufferedInputStream inStrm = new BufferedInputStream( new FileInputStream(inFile)); BufferedOutputStream outStrm = new BufferedOutputStream( new FileOutputStream(“E:”+owner+”1.txt”)); System.err.println(“Buffer size = ” + inputLength); byte buf = new byteinputLength; System.out.println(“^^^^^^=====”+new String(buf)); int nBytes = inStrm.read(buf); System.out.println(“” + nBytes + ” bytes read”); byte msg = new bytenBytes; System.arraycopy(buf, 0, msg, 0, nBytes); System.out.println(“=====”+new String(msg)); byte tmsg = trfmr.transform(msg); System.out.println(“” + tmsg.length + ” bytes produced”); System.out.println(“encrypte message” +new String(tmsg) ); outStrm.write(tmsg); inStrm.close(); outStrm.close(); return new String(tmsg); }}
- Home/
- Essay Types/
- Analytical Essays/
- Argumentative Essays/
- Autobiography Essays/
- Cause and Effect Essays/
- Classification Essays/
- Compare and Contrast Essays/
- Controversial Essays/
- Creative Essays/
- Critical Essays/
- Definition Essays/
- Descriptive Essays/
- Evaluation Essays/
- Exemplification Essays/
- Exploratory Essays/
- Expository Essays/
- Informative Essays/
- Memoir Essays/
- Narrative Essays/
- Personal Statement Essays/
- Persuasive Essays/
- Process Essays/
- Profile Essays/
- Proposal Essays/
- Reflective Essays/
- Research Essays/
- Response Essays/
- Rhetorical Essays/
- Satire Essays/
- Synthesis Essays/
- Essay samples/
- Hire Writer/
- Contact US/