Mercurial > projects > dcrypt
view 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 |
line wrap: on
line source
/** * This file is part of the dcrypt project. * * Copyright: Copyright (C) dcrypt contributors 2008. All rights reserved. * License: MIT * Authors: Thomas Dixon */ module dcrypt.crypto.Crypto; import dcrypt.crypto.SymmetricCipher; import dcrypt.misc.Util; // Hash functions public import dcrypt.crypto.Hash; import dcrypt.crypto.hashes.MD5; import dcrypt.crypto.hashes.SHA1; import dcrypt.crypto.hashes.SHA224; import dcrypt.crypto.hashes.SHA256; import dcrypt.crypto.hashes.SHA384; import dcrypt.crypto.hashes.SHA512; struct Crypto { static Hash hashByName(char[] name) { switch (Util.stringToAlphanumeric(Util.stringToUpper(name))) { case "MD5": return new MD5(); case "SHA1": return new SHA1(); case "SHA224": return new SHA224(); case "SHA256": return new SHA256(); case "SHA384": return new SHA384(); case "SHA512": return new SHA512(); default: throw new InvalidParameterError("Unknown hash function: "~name); } } }