Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Other Java > BOOK: Beginning Cryptography with Java
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Cryptography with Java
This is the forum to discuss the Wrox book Beginning Cryptography with Java by David Hook; ISBN: 9780764596339
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Cryptography with Java section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 10th, 2007, 09:45 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Identifying a PGP file

Is there a way to identify a PGP encrypted file based on the file content (like the way a ZIP file can be identified by looking for letters "PK" at the beginning of the file)? We receive multiple files from a client and don't have an idea which ones are PGP encrypted. I need to write code to identify the PGP files and decrypt them automatically. Thanks!!
Reply With Quote
  #2 (permalink)  
Old July 11th, 2007, 04:37 AM
dgh dgh is offline
Wrox Author
Points: 864, Level: 11
Points: 864, Level: 11 Points: 864, Level: 11 Points: 864, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2005
Location: , , .
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

The best I could suggest is to look for a PGP packet header in the file - there isn't a magic number associated with PGP files. You'd need to do some analysis on the files you have and look for packet types, internally consistent length headers and the like.

Regards,

David

Reply With Quote
  #3 (permalink)  
Old July 12th, 2007, 10:47 AM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks David!!

One more question. I wrote a progam to encrypt a file using a public key. I don't have the private key with me to decrypt the file. How do I know if the encryption was successful?

The file was encrypted using a PGP tool previously and I have a copy of the previously encrypted file. Is there a way to compare (byte comparison or something) this previously encrpted file with the one that I encrypted via programming to make they are the same?

Thanks!!

Reply With Quote
  #4 (permalink)  
Old July 12th, 2007, 07:31 PM
dgh dgh is offline
Wrox Author
Points: 864, Level: 11
Points: 864, Level: 11 Points: 864, Level: 11 Points: 864, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2005
Location: , , .
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

The session key used to encrypt the file is random, so it would be highly unusual for two encryptions of the same file to produce the same encrypted data.

The best way to confirm your program is working is to generate your own public/private key pair, do an encryption, and use another tool like GPG to decrypt the file.

Regards,

David

Reply With Quote
  #5 (permalink)  
Old July 13th, 2007, 04:05 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks David!!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Decrypting pgp files with vbscript tonyromero99 VBScript 4 June 4th, 2008 04:09 AM
PGP Encryption everest C# 2005 4 October 28th, 2007 08:20 PM
IDENTIFYING THE PORTS abdul_owiusa C# 3 August 7th, 2004 04:11 AM
pgp file? ktchlin C# 1 July 26th, 2004 07:49 AM
PGP (GPG) / PHP Help! URGENT!!!!!!!! cmiller PHP How-To 1 July 13th, 2004 06:19 AM



All times are GMT -4. The time now is 05:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.