When I reproduce a SHA2 hash via the following code:
MessageDigest digest = MessageDigest.getInstance(\"SHA-256\"); digest.digest(\"A\".getBytes(\"UTF-8\"));
Integer.toHexString(0XFF & i) must be replaced with String.format("%02x", 0XFF & i), otherwise it only produces a 1 character output, while 2 characters are expected.
Integer.toHexString(0XFF & i)
String.format("%02x", 0XFF & i)