Mercurial > projects > dcrypt
view dcrypt/crypto/PRNG.d @ 36:fc97fffd106d default tip
Added tag 0.1 for changeset 6b2c35b84186
author | Thomas Dixon <reikon@reikon.us> |
---|---|
date | Thu, 14 May 2009 17:46:46 -0400 |
parents | 2b4bccdc8387 |
children |
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.PRNG; public import dcrypt.crypto.errors.ShortBufferError; public import dcrypt.crypto.errors.NotInitializedError; public import dcrypt.crypto.errors.InvalidParameterError; public import dcrypt.crypto.errors.NotSupportedError; /** Relatively simple interface for PRNGs. */ abstract class PRNG { protected bool _initialized; /** Returns: Whether or not the PRNG has been initialized. */ bool initialized() { return _initialized; } /** * Introduce entropy into the PRNG. An initial call to this is * usually required for seeding. * * Params: * input = Bytes to introduce into the PRNG as entropy */ void addEntropy(void[] input); /** Play nice with D2's idea of const. */ version (D_Version2) { void addEntropy(string input) { addEntropy(cast(ubyte[])input); } } /** * Read bytes from the keystream of the PRNG into output. * * Params: * output = Array to fill with the next bytes of the keystream */ uint read(void[] output_); /** Returns: The name of the PRNG algorithm */ string name(); }