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 September 11th, 2009, 07:05 PM
Registered User
 
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 3 Utils methods

Thanks for the great book. After spending fruitless hours with cryptic (pun intended) JCE documentation, your book makes JCE concepts crystal clear.

Chapter 3 gives a utility class for byte->string->byte conversions, however:
Code:
// where s is a UTF-8 string 
chapter3.Utils.toString(chapter3.Utils.toByteArray(s));
mangles non-ascii characters where as
Code:
new String(s.getBytes());
returns the original string s as expected. Can you please explain?

thanks
tom
Reply With Quote
  #2 (permalink)  
Old September 11th, 2009, 11:54 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 method guarantees that the string is converted on the basis that it's 8 bit ascii, so yes, it wouldn't work for UTF-8.

The reason behind it was to avoid issues with the examples that were related to getBytes(), the default conversion is platform dependent, and not all platforms support the same byte encodings.

Regards,

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
Chapter 7 : Wrong SQLDataProvider methods claudiotereso BOOK: Professional DotNetNuke Module Programming ISBN: 978-0-470-17116-5 1 March 4th, 2009 11:13 AM
String Utils to search all words in filenames sbc789 JSP Basics 1 December 7th, 2008 10:39 PM
problem on Utils.java of chapter7 Jim0602 BOOK: Beginning Cryptography with Java 2 June 2nd, 2007 12:55 AM
METHODS magagulad Java GUI 3 May 15th, 2007 12:53 PM
Chapter 5 Shadowing Shared Methods ahanshew BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 0 February 23rd, 2006 04:06 PM



All times are GMT -4. The time now is 01:49 PM.


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