turcsanyip commented on code in PR #10746:
URL: https://github.com/apache/nifi/pull/10746#discussion_r2678905459


##########
nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureStorageUtils.java:
##########
@@ -192,6 +193,21 @@ public final class AzureStorageUtils {
             .description("Specifies whether an existing blob will have its 
contents replaced upon conflict.")
             .build();
 
+    public static final PropertyDescriptor CONTENT_MD5 = new 
PropertyDescriptor.Builder()
+            .name("Content MD5")
+            .displayName("Content MD5")
+            .description("""
+                    The MD5 hash of the content. When this property is set, 
Azure will validate
+                    the uploaded content against this checksum and reject the 
upload if it doesn't match. This provides

Review Comment:
   ADLS does not seem to validate the checksum, just stores whatever passed in. 
It may be worth mentioning it in the description of the property on the ADLS 
processor in order to avoid confusion and set expectations. The current 
description is appropriate for blob storage.



##########
nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureStorageUtils.java:
##########
@@ -354,6 +370,28 @@ private static ProxyOptions.Type 
getProxyType(ProxyConfiguration proxyConfigurat
         }
     }
 
+    /**
+     * Converts an MD5 checksum string to bytes. Accepts both hexadecimal 
format (as output by CryptographicHashContent)
+     * and Base64 format.
+     *
+     * @param md5String the MD5 checksum as hex (32 chars) or Base64 (24 chars 
with padding)
+     * @return the MD5 as a 16-byte array
+     */
+    public static byte[] convertMd5ToBytes(final String md5String) {
+        // MD5 in hex format is 32 characters (128 bits = 16 bytes, 2 hex 
chars per byte)
+        if (md5String.length() == 32 && md5String.matches("[0-9a-fA-F]+")) {
+            // Convert hex to bytes
+            final byte[] bytes = new byte[16];
+            for (int i = 0; i < 16; i++) {
+                bytes[i] = (byte) Integer.parseInt(md5String.substring(i * 2, 
i * 2 + 2), 16);
+            }
+            return bytes;

Review Comment:
   `java.util.HexFormat` could be used:
   ```suggestion
               return HexFormat.of().parseHex(md5String);
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to