From cb28ec625a8f96e88a1668da3d0fa51a365f8b8a Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 10 Feb 2021 13:27:20 +0700 Subject: Add TestRandomData class --- crypto/test/src/util/test/TestRandomData.cs | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 crypto/test/src/util/test/TestRandomData.cs (limited to 'crypto/test/src/util') diff --git a/crypto/test/src/util/test/TestRandomData.cs b/crypto/test/src/util/test/TestRandomData.cs new file mode 100644 index 000000000..7fe0cf305 --- /dev/null +++ b/crypto/test/src/util/test/TestRandomData.cs @@ -0,0 +1,33 @@ +using System; + +using Org.BouncyCastle.Utilities.Encoders; + +namespace Org.BouncyCastle.Utilities.Test +{ + /** + * A fixed secure random designed to return data for someone needing random bytes. + */ + public class TestRandomData + : FixedSecureRandom + { + /** + * Constructor from a Hex encoding of the data. + * + * @param encoding a Hex encoding of the data to be returned. + */ + public TestRandomData(string encoding) + : this(Hex.Decode(encoding)) + { + } + + /** + * Constructor from an array of bytes. + * + * @param encoding a byte array representing the data to be returned. + */ + public TestRandomData(byte[] encoding) + : base(new FixedSecureRandom.Source[] { new FixedSecureRandom.Data(encoding)}) + { + } + } +} -- cgit 1.5.1