|
string | hash (string data, int subfolders, string dirSeparator) |
| Builds a key for the cached version, using the hashcode of the normalized URL. if subfolders > 1, dirSeparator will be used to separate the subfolder and the key. No extension is appended. I.e, a13514\124211ab132592 or 12412ababc12141 More...
|
|
|
string | getSubfolder (byte[] hash, int subfolders) |
| Returns a string for the subfolder name. The bits used are from the end of the hash - this should make the hashes in each directory more unique, and speed up performance (8.3 filename calculations are slow when lots of files share the same first 6 chars. Returns null if not configured. Rounds subfolders up to the nearest power of two. More...
|
|
string | Base16Encode (byte[] bytes) |
|
Definition at line 11 of file UrlHasher.cs.
string ImageResizer.Plugins.DiskCache.UrlHasher.getSubfolder |
( |
byte[] |
hash, |
|
|
int |
subfolders |
|
) |
| |
|
inlineprotected |
Returns a string for the subfolder name. The bits used are from the end of the hash - this should make the hashes in each directory more unique, and speed up performance (8.3 filename calculations are slow when lots of files share the same first 6 chars. Returns null if not configured. Rounds subfolders up to the nearest power of two.
- Parameters
-
- Returns
Definition at line 48 of file UrlHasher.cs.
49 int bits = (int)Math.Ceiling(Math.Log(subfolders, 2));
50 Debug.Assert(bits > 0);
51 Debug.Assert(bits <= hash.Length * 8);
53 byte[] subfolder =
new byte[(int)Math.Ceiling((
double)bits / 8.0)];
54 Array.Copy(
hash, hash.Length - subfolder.Length, subfolder, 0, subfolder.Length);
55 subfolder[0] = (byte)((
int)subfolder[0] >> ((subfolder.Length * 8) - bits));
56 return Base16Encode(subfolder);
string hash(string data, int subfolders, string dirSeparator)
Builds a key for the cached version, using the hashcode of the normalized URL. if subfolders > 1...
string ImageResizer.Plugins.DiskCache.UrlHasher.hash |
( |
string |
data, |
|
|
int |
subfolders, |
|
|
string |
dirSeparator |
|
) |
| |
|
inline |
Builds a key for the cached version, using the hashcode of the normalized URL. if subfolders > 1, dirSeparator will be used to separate the subfolder and the key. No extension is appended. I.e, a13514\124211ab132592 or 12412ababc12141
- Parameters
-
data | |
subfolders | |
dirSeparator | |
- Returns
Definition at line 25 of file UrlHasher.cs.
27 SHA256 h = System.Security.Cryptography.SHA256.Create();
28 byte[]
hash = h.ComputeHash(
new System.Text.UTF8Encoding().GetBytes(data));
31 string subfolder =
"";
33 subfolder =
getSubfolder(hash, subfolders) + dirSeparator;
38 return subfolder + Base16Encode(hash);
string hash(string data, int subfolders, string dirSeparator)
Builds a key for the cached version, using the hashcode of the normalized URL. if subfolders > 1...
string getSubfolder(byte[] hash, int subfolders)
Returns a string for the subfolder name. The bits used are from the end of the hash - this should mak...
The documentation for this class was generated from the following file:
- C:/Users/nathanael/Documents/resizer/Plugins/DiskCache/UrlHasher.cs