symat commented on a change in pull request #2539:
URL: https://github.com/apache/hbase/pull/2539#discussion_r520005148



##########
File path: 
hbase-common/src/main/java/org/apache/hadoop/hbase/io/crypto/Encryption.java
##########
@@ -215,7 +215,7 @@ public static boolean 
failOnHashAlgorithmMismatch(Configuration conf) {
    * Return the MD5 digest of the concatenation of the supplied arguments.
    */
   public static byte[] hash128(String... args) {
-    return hashWithAlg("MD5", args);
+    return hashWithAlg("MD5", Bytes.toByteArrays(args));

Review comment:
       so hashWithAlg takes any number of byte arrays, and don't use 
Bytes.toBytes(). 
   (Bytes.toBytes was used e.g. by the old `hash128(String... args)` function I 
refactored)
   
   So in my code: 
   ```
    public static byte[] hashWithAlg(String algorithm, byte[]... args) {
       try {
         MessageDigest md = MessageDigest.getInstance(algorithm);
         for (byte[] arg: args) {
           md.update(arg);
         }
         return md.digest();
       } catch (NoSuchAlgorithmException e) {
         throw new RuntimeException("unable to use hash algorithm: " + 
algorithm, e);
       }
     }
   
   ```
   
   And here in `hash128` we are using the `Bytes.toByteArrays` function to 
convert the `String... args` to `byte[][]`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to