Skip to content

Replace deprecated CC_MD5 with CC_SHA256 for disk cache filename generation - #3885

Open
PullaguraSatish wants to merge 1 commit into
SDWebImage:masterfrom
PullaguraSatish:feature/replace-md5-with-sha256
Open

PullaguraSatish wants to merge 1 commit into
SDWebImage:masterfrom
PullaguraSatish:feature/replace-md5-with-sha256

Conversation

@PullaguraSatish

@PullaguraSatish PullaguraSatish commented Aug 6, 2026

Copy link
Copy Markdown

Summary

This PR replaces the deprecated CC_MD5 APIs with CC_SHA256 when generating hashed disk cache filenames.

Motivation

Apple has deprecated the CC_MD5 APIs, and many security analysis tools flag MD5 usage even when it is used only for deterministic filename generation. This change updates the implementation to use SHA-256 while preserving the existing filename generation logic.

Changes

  • Replaced CC_MD5 with CC_SHA256.
  • Updated the digest buffer from CC_MD5_DIGEST_LENGTH to CC_SHA256_DIGEST_LENGTH.
  • Updated SD_MAX_FILE_EXTENSION_LENGTH to account for the larger SHA-256 digest.
  • Expanded the generated hexadecimal filename from 16 bytes (32 hex characters) to 32 bytes (64 hex characters).

Impact

This change only affects the hashed filenames generated for disk cache entries. Existing cache files generated using MD5 will not be reused and may be regenerated after upgrading. No changes are made to the public API or image loading behavior.

Testing

  • Verified the project builds successfully.
  • Verified disk cache filename generation using SHA-256.
  • Verified image loading and disk caching continue to function as expected.

Summary by CodeRabbit

  • Bug Fixes
    • Improved disk-cache filename hashing for stronger collision resistance.
    • Updated cache filename handling to support the expanded hash format without affecting cached image retrieval.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 547a7f94-74c4-47cc-8578-dfe999854416

📥 Commits

Reviewing files that changed from the base of the PR and between c3ad5e1 and d839a35.

📒 Files selected for processing (1)
  • SDWebImage/Core/SDDiskCache.m

📝 Walkthrough

Walkthrough

SDDiskCacheFileNameForKey now uses SHA-256 instead of MD5. It generates 64-character hexadecimal digests and adjusts extension limits while preserving optional sanitized extensions.

Changes

Disk cache filename hashing

Layer / File(s) Summary
Generate SHA-256 cache filenames
SDWebImage/Core/SDDiskCache.m
The cache filename generator computes SHA-256, serializes all 32 digest bytes, and reserves space for the 64-character digest before adding an optional extension.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing deprecated CC_MD5 with CC_SHA256 for disk cache filename generation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant