/* java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.math.BigInteger;/** * *

Topic: LifeDream
Sample donated:
Last updated: March 13, 2019

/* * 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);    }}

Choose your subject

x

Hi!
I'm Jessica!

Don't know how to start your paper? Worry no more! Get professional writing assistance from me.

Click here