Let's say I convert my string into byte array.
byte byte sUserID.getBytes(“UTF-8”); //Convert User ID String to byte array
Now I need to write a script on Shell that will have exactly the same functionality as my Java code. At some stage I must hash my byte array (using
MessageDigest.getInstance(“SHA-256”) in Java and
openssl dgst -sha256 –binary in Shell), but because digests in Java code are generated from byte arrays, they won’t match results I get in Shell (in Shell I simply hash strings at the moment, so input formats don't match).
Because my input for
openssl in shell should be similar to Java input I want to know whether there is a way to “simulate”
getBytes() method in Shell? I don’t have much experience in Shell so I don’t know what could be the best approach in this case. Any ideas? Cheers!