hi:
I have written a simple program to encrypt files using PGP, cryptix
API. The encrypted output can be decrypted by PGP freeware 8.0.3
software. However, if I try to encrypt the file with PGP freeware, the
encrypted output produced by my code doesnt match in size to the
encrypted file produced by PGP freeware 8.0.3.
My input file size is 12kb , size of output produced by my code :
16kb
size of output producded by PGP s/w : 3kb.
Any pointers into this would be apprecited,as I would like to use my
code encrypt very large files.
Here is the code I am using for PGP encryption.
/*the code below has been stripped of exception handling code*/
PGPKeyBundle bundle = null;
MessageFactory messageFactory;
bundle = readKeyFile(keyFile);
LiteralMessage litmsg;
String msg = new String();
java.io.BufferedReader in = new
java.io.BufferedReader(new
java.io.FileReader(new java.io.File(textFile)));
String line = null;
while ((line=in.readLine()) != null) {
msg = msg.concat(line);
msg = msg.concat("\n");
}
in.close();
LiteralMessageBuilder lmb = LiteralMessageBuilder.getInstance
("OpenPGP");
lmb.init(msg);
litmsg = (LiteralMessage) lmb.build();
EncryptedMessageBuilder encryptedMessageBuilder =
EncryptedMessageBuilder.getInstance("OpenPGP");
encryptedMessageBuilder.init(litmsg);
encryptedMessageBuilder.addRecipient(bundle);
message = encryptedMessageBuilder.build();
PGPArmouredMessage armoured;
armoured = new PGPArmouredMessage(message);
FileOutputStream out = new
FileOutputStream(encryptedFile);
out.write(armoured.getEncoded());
out.close();
TIA
sp
Roedy Green - 15 Mar 2004 20:42 GMT
>Any pointers into this would be apprecited,as I would like to use my
>code encrypt very large files.
You probably want to zip them first. see
http://mindprod.com/fileio.html
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.