Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / March 2004

Tip: Looking for answers? Try searching our database.

size of cryptix PGP encrypted file doesnt match PGP freeware encryted file

Thread view: 
sp - 12 Mar 2004 22:30 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.