apache / tsfile

Apache TsFile
https://tsfile.apache.org/
Apache License 2.0
104 stars 50 forks source link

Fix code scanning alert no. 12: Use of a broken or risky cryptographic algorithm #291

Closed HTHou closed 2 weeks ago

HTHou commented 2 weeks ago

Fixes https://github.com/apache/tsfile/security/code-scanning/12

To fix the problem, we need to replace the use of the MD5 algorithm with a stronger, modern cryptographic algorithm such as SHA-256. This involves updating the MessageDigest.getInstance("MD5") call to use SHA-256 instead. The rest of the code logic can remain the same, as SHA-256 provides a similar interface to MD5.

Steps to fix:

  1. Update the MessageDigest.getInstance("MD5") call to MessageDigest.getInstance("SHA-256") in both getNormalKeyStr methods.
  2. Ensure that the rest of the code correctly handles the output of the SHA-256 hash, which is longer than the MD5 hash.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.