base64 v DataOutputStream
There is a missing element here of how it is that original poster is stuck with going through a string, I noticed in ftr's comments in the base64 encoder something to the effect of may not be reversable. As Norm states, it is how opie converts in the first place that matters for getting data back to bin - hex - octets but going through String method seems to introduce indefinite risks surrounding contemporary String ( ususaly viewed as human-readable or at least containing few if any nulls ) vis-a-vis byte / binary data transmission. Those are distinguishable problem domains.
{Norm, I got a couple of 500-800 page Java books back from my bench tech, let me know if you want me to ship them to you as they are not being used by me any more.}
Additional query with the same problem
When I am running the code as follows:
BufferedReader userInput = new BufferedReader (new InputStreamReader(System.in));
System.out.println("Enter String: ");
String input = userInput.readLine();
System.out.println("UserInput:"+input);
byte[] sha1hash = input.getBytes();
System.out.println("ByteFormat:"+sha1hash);
String t = new String( sha1hash);
System.out.println("StringFormat:"+t);
for (int i = 0; i < sha1hash.length; i++)
System.out.println("ByteArray["+i+"]:"+sha1hash[i]);
I am getting the output as follows:
Enter String:
23
UserInput:23
ByteFormat:[B@10b62c9
StringFormat:23
ByteArray[0]:50
ByteArray[1]:51
I am unable to understand that when I am printing each element of the byte array where from it is getting those values.