I'm using openssl dgst -sha1 -binary to get hash values of my strings in binary format.
(I'm using -binary flag because my version of openssl adds "stdout" before each hash value on default output, and -binary helps to avoid it, therefore it's easier to store hash results in binary format for further processing (so I can just use xxd -p when I want hex values instead of manually cutting out that "stdout" from each string)
So, the binary output of openssl dgst -sha1 -binary for a "Hello!" string in Cygwin console will look like this: _▒▒"q▒%▒a▒▒▒▒.&C▒0N▒Q▒▒vH&8i
Now I create a new variable with this result and concatenate it with another variable, which value is not in binary format (i.e. "World"). So my new variable now looks like
_▒▒"q▒%▒a▒▒▒▒.&C▒0N▒Q▒▒vH&8iWorld
Then I generate another hash for this concatenated string and compare it to the one I got using default Java hashing libraries (MessageDigest). On this step, however, hashes obtained via shell and Java don't match (and I need to get exactly the same value as the one generated on Java side).
So I suppose that my "World" string should be in binary format as well to match my Java hash output (because as long as I generate hashes for concatenated binary values all hashes match). However, I don't know how to convert my "World" string to binary format in shell. Any ideas?
"Hello!"and"World"?