I have code that works well on Android. When I ported it to my Windows 64-bit machine with JRE 1.6, the code did not work.
When I run the following line of code:
When in doubt over what algorithms you can use for a JCA service, your first port of call should be the JCA Standard Algorithm Name Documentation. The algorithms guaranteed to be supported by the MessageDigest service in a JCA-compliant JVM are:
MD2
MD5
SHA-1
SHA-256
SHA-384
SHA-512
It's common for providers to supply aliases for these algorithms, which is why it'd probably work with Bouncy Castle, but you should stick to these if you can to maximise portability.
If you change your code to the following, it will work as expected:
final MessageDigest digest = MessageDigest.getInstance("SHA-256");
SHA-256 should be the parameter to getInstance()
Link for the list of algorithms supported for message digest