getBytes() - Encoding Style problem
Hi people,
I need to encrypt a password using SHA algorithm through the MessageDigest object. Initially, I need obtain the bytes of the password String in order to pass it to the update() method of the mentioned object.
The problem is that the getBytes() method return different values on different platforms. I am using Windows and Sun Solaris OSs. I also noticed that even on the same OS, changing the jdk version will return in different result for the same String.
Could you please help me with this issue because it is getting very frustrating.
Regards George
# 7
> I already used getBytes("UTF-8"), however on UNIX
> machine i am getting a different value than on a
> Windows machine.
I doubt it!
>
> Could it be different jvm versions on different
> machines?
No! You have a coding error. You need to post all your code.
# 8
The code is very simple.
System.out.println("TEST".getBytes("UTF-8"));
I am using jvm 1.5.0_04 both on Windows and Unix. On Windows, the above statement is returning [B@6b97fd while on Unix it is returning [B@e48e1b.
I don't know what's wrong with this. Maybe I have a misconception of some principles.
Thanks for your support
Regards
George
# 9
That statement doesn't print the contents of the array, it prints whatever byte[].toString() prints. Try looking inside, at the elements of the array.
ejpa at 2007-7-12 19:43:35 >
