parseCryptHash

Parses a string that was encoded by Hash.toString.

Only OO-style digests are used since the digest is specified in the string and therefore only known at runtime.

Throws ConvException if the string is malformed.

To support additional digests besides the built-in (Phobos's CRC32, MD5, RIPEMD160 and SHA), supply a custom delegate for digestFromDAuthCode. You can defer to DAuth's defaultDigestFromCode to handle the built-in digests.

Similarly, to extend crypt(3)-style to support additional digests beyond DAuth's crypt(3) support, supply a custom delegate for digestFromCryptCode. The default implementation is defaultDigestFromCryptCode.

Examples

1 import std.digest.digest;
2 import dauth;
3 
4 struct BBQ42 {...}
5 static assert(isDigest!BBQ42);
6 alias BBQ42Digest = WrapperDigest!BBQ42;
7 
8 Digest customDigestFromCode(string digestCode)
9 {
10     switch(digestCode)
11     {
12     case "BBQ42": return new BBQ42Digest();
13     case "FAQ17": return new FAQ17Digest();
14     default:
15         return defaultDigestFromCode(digestCode);
16     }
17 }
18 
19 void doStuff(string hashString)
20 {
21     auto hash = parseHash(hashString, &customDigestFromCode);
22 }

Optional Params

digestFromDAuthCode - Default value is 'toDelegate(&defaultDigestFromCode)'

digestFromCryptCode - Default value is 'toDelegate(&defaultDigestFromCryptCode)'

Meta