Matching Java SHA2 Output vs MySQL SHA2 Output

前端 未结 2 1307
一个人的身影
一个人的身影 2021-02-11 09:42

When I reproduce a SHA2 hash via the following code:

MessageDigest digest = MessageDigest.getInstance(\"SHA-256\");
digest.digest(\"A\".getBytes(\"UTF-8\"));
         


        
2条回答
  •  渐次进展
    2021-02-11 10:20

    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.

提交回复
热议问题