parseHash

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.

  1. Hash!Digest parseHash(string str, Digest delegate(string) digestFromDAuthCode = toDelegate(&defaultDigestFromCode), Digest delegate(string) digestFromCryptCode = toDelegate(&defaultDigestFromCryptCode))
    Hash!Digest
    parseHash
    (
    string str
    ,
    Digest delegate(
    string
    )
    digestFromDAuthCode = toDelegate(&defaultDigestFromCode)
    ,
    Digest delegate(
    string
    )
    digestFromCryptCode = toDelegate(&defaultDigestFromCryptCode)
    )
  2. Hash!Digest parseDAuthHash(string str, Digest delegate(string) digestFromDAuthCode = toDelegate(&defaultDigestFromCode))
  3. Hash!Digest parseCryptHash(string str, Digest delegate(string) digestFromCryptCode = toDelegate(&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