Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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
 
Old September 11th, 2009, 11:54 PM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
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





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





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