| Issue 2544: | DiskBasedCache#getFilenameForKey return not unique filename | |
| 1 person starred this issue and may be notified of changes. | Back to list |
************************************************************ ***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW ***** ***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL ***** ***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC. ***** ***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS! ***** ************************************************************ ex) DiskBasedCache#getFilenameForKey - https://xxxxxxxxxxxxxxxxxxxxxxx.amazonaws.com/img/photo/201403/7e5.jpg - https://xxxxxxxxxxxxxxxxxxxxxxx.amazonaws.com/img/photo/201403/7cs.jpg same result "808332816233036336" Using SHA: private static MessageDigest md; static { try { // NOTE: SHA-256 better? md = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } private String getFilenameForKey(String key) { if (md != null) { byte[] digest; synchronized (md) { md.update(key.getBytes()); digest = md.digest(); } StringBuilder sb = new StringBuilder(digest.length * 2); for (byte b: digest) { sb.append(String.format("%02x", b)); } return new String(sb); } int firstHalfLength = key.length() / 2; String localFilename = String.valueOf(key.substring(0, firstHalfLength).hashCode()); localFilename += String.valueOf(key.substring(firstHalfLength).hashCode()); return localFilename; }
Mar 12, 2014
#1
y.uzum...@gmail.com
Mar 12, 2014
This is the issue tracker for Gerrit Code Review.
Status:
Invalid
Mar 12, 2014
Oh, sorry. Do you know how to com.android.volley bug report?
Mar 12, 2014
I come from https://android-review.googlesource.com/#/q/status:open+project:platform/frameworks/volley
Mar 12, 2014
The best way is to upload a change with a rough proposed fix. See https://source.android.com/source/submit-patches.html and https://source.android.com/source/report-bugs.html for details.
Mar 12, 2014
Thank you for giving me good advice :) |
|
| ► Sign in to add a comment |