Mercurial > projects > dcrypt
annotate dcrypt/crypto/Crypto.d @ 9:29b910949588
Minor edit of Crypto class to make the lib actually compile.
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Mon, 18 Aug 2008 01:19:18 -0400 |
parents | 0e08791a1418 |
children | cd376996cdb3 |
rev | line source |
---|---|
0 | 1 /** |
2 * This file is part of the dcrypt project. | |
3 * | |
4 * Copyright: Copyright (C) dcrypt contributors 2008. All rights reserved. | |
5 * License: MIT | |
6 * Authors: Thomas Dixon | |
7 */ | |
8 | |
9 module dcrypt.crypto.Crypto; | |
10 | |
9
29b910949588
Minor edit of Crypto class to make the lib actually compile.
Thomas Dixon <reikon@reikon.us>
parents:
0
diff
changeset
|
11 import dcrypt.crypto.SymmetricCipher; |
0 | 12 |
13 import dcrypt.misc.Util; | |
14 | |
15 // Hash functions | |
16 public import dcrypt.crypto.Hash; | |
17 import dcrypt.crypto.hashes.MD5; | |
18 import dcrypt.crypto.hashes.SHA1; | |
19 import dcrypt.crypto.hashes.SHA224; | |
20 import dcrypt.crypto.hashes.SHA256; | |
21 import dcrypt.crypto.hashes.SHA384; | |
22 import dcrypt.crypto.hashes.SHA512; | |
23 | |
24 struct Crypto { | |
25 static Hash hashByName(char[] name) { | |
26 switch (Util.stringToAlphanumeric(Util.stringToUpper(name))) { | |
27 case "MD5": | |
28 return new MD5(); | |
29 case "SHA1": | |
30 return new SHA1(); | |
31 case "SHA224": | |
32 return new SHA224(); | |
33 case "SHA256": | |
34 return new SHA256(); | |
35 case "SHA384": | |
36 return new SHA384(); | |
37 case "SHA512": | |
38 return new SHA512(); | |
39 default: | |
40 throw new InvalidParameterError("Unknown hash function: "~name); | |
41 } | |
42 } | |
43 } |