КриптоПро .NET
Search Results for

    Показать/Скрыть содержание

    Class CpRandomNumberGenerator

    Inheritance
    object
    RandomNumberGenerator
    CpRandomNumberGenerator
    GostRngCryptoServiceProvider
    Implements
    IDisposable
    Inherited Members
    RandomNumberGenerator.Dispose()
    RandomNumberGenerator.Dispose(bool)
    RandomNumberGenerator.GetBytes(byte[])
    RandomNumberGenerator.GetBytes(byte[], int, int)
    RandomNumberGenerator.GetBytes(Span<byte>)
    RandomNumberGenerator.GetNonZeroBytes(byte[])
    RandomNumberGenerator.GetNonZeroBytes(Span<byte>)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: CryptoPro.Security.Cryptography
    Assembly: CryptoPro.Security.Cryptography.dll
    Syntax
    public abstract class CpRandomNumberGenerator : RandomNumberGenerator, IDisposable

    Methods

    Create()

    Declaration
    public static CpRandomNumberGenerator Create()
    Returns
    Type Description
    CpRandomNumberGenerator

    Create(string)

    Declaration
    [Obsolete("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId = "SYSLIB0045", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
    public static CpRandomNumberGenerator? Create(string rngName)
    Parameters
    Type Name Description
    string rngName
    Returns
    Type Description
    CpRandomNumberGenerator

    Fill(Span<byte>)

    Declaration
    public static void Fill(Span<byte> data)
    Parameters
    Type Name Description
    Span<byte> data

    GetBytes(int)

    Creates an array of bytes with a cryptographically strong random sequence of values.

    Declaration
    public static byte[] GetBytes(int count)
    Parameters
    Type Name Description
    int count

    The number of bytes of random values to create.

    Returns
    Type Description
    byte[]

    An array populated with cryptographically strong random values.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    count is less than zero.

    GetHexString(int, bool)

    Creates a string filled with cryptographically random hexadecimal characters.

    Declaration
    public static string GetHexString(int stringLength, bool lowercase = false)
    Parameters
    Type Name Description
    int stringLength

    The length of string to create.

    bool lowercase

    true if the hexadecimal characters should be lowercase; false if they should be uppercase. The default is false.

    Returns
    Type Description
    string

    A string populated with random hexadecimal characters.

    Remarks

    The behavior of this is the same as using GetString(ReadOnlySpan<char>, int) and specifying hexadecimal characters as the choices. This implementation is optimized specifically for hexadecimal characters.

    GetHexString(Span<char>, bool)

    Fills a buffer with cryptographically random hexadecimal characters.

    Declaration
    public static void GetHexString(Span<char> destination, bool lowercase = false)
    Parameters
    Type Name Description
    Span<char> destination

    The buffer to receive the characters.

    bool lowercase

    true if the hexadecimal characters should be lowercase; false if they should be uppercase. The default is false.

    Remarks

    The behavior of this is the same as using GetItems<T>(ReadOnlySpan<T>, Span<T>) and specifying hexadecimal characters as the choices. This implementation is optimized specifically for hexadecimal characters.

    GetInt32(int)

    Declaration
    public static int GetInt32(int toExclusive)
    Parameters
    Type Name Description
    int toExclusive
    Returns
    Type Description
    int

    GetInt32(int, int)

    Declaration
    public static int GetInt32(int fromInclusive, int toExclusive)
    Parameters
    Type Name Description
    int fromInclusive
    int toExclusive
    Returns
    Type Description
    int

    GetItems<T>(ReadOnlySpan<T>, int)

    Creates an array populated with items chosen at random from choices.

    Declaration
    public static T[] GetItems<T>(ReadOnlySpan<T> choices, int length)
    Parameters
    Type Name Description
    ReadOnlySpan<T> choices

    The items to use to populate the array.

    int length

    The length of array to return populated with items.

    Returns
    Type Description
    T[]

    An array populated with random choices.

    Type Parameters
    Name Description
    T

    The type of items.

    Exceptions
    Type Condition
    ArgumentException

    choices is empty.

    ArgumentOutOfRangeException

    length is not zero or a positive number.

    See Also
    GetString(ReadOnlySpan<char>, int)
    GetHexString(Span<char>, bool)

    GetItems<T>(ReadOnlySpan<T>, Span<T>)

    Fills the elements of a specified span with items chosen at random from the provided set of choices.

    Declaration
    public static void GetItems<T>(ReadOnlySpan<T> choices, Span<T> destination)
    Parameters
    Type Name Description
    ReadOnlySpan<T> choices

    The items to use to fill the buffer.

    Span<T> destination

    The buffer to receive the items.

    Type Parameters
    Name Description
    T

    The type of items.

    Exceptions
    Type Condition
    ArgumentException

    choices is empty.

    See Also
    GetString(ReadOnlySpan<char>, int)
    GetHexString(Span<char>, bool)

    GetString(ReadOnlySpan<char>, int)

    Creates a string populated with characters chosen at random from choices.

    Declaration
    public static string GetString(ReadOnlySpan<char> choices, int length)
    Parameters
    Type Name Description
    ReadOnlySpan<char> choices

    The characters to use to populate the string.

    int length

    The length of string to return.

    Returns
    Type Description
    string

    A string populated with random choices.

    Exceptions
    Type Condition
    ArgumentException

    choices is empty.

    ArgumentOutOfRangeException

    length is not zero or a positive number.

    See Also
    GetItems<T>(ReadOnlySpan<T>, Span<T>)
    GetItems<T>(ReadOnlySpan<T>, int)
    GetHexString(Span<char>, bool)

    Shuffle<T>(Span<T>)

    Performs an in-place shuffle of a span using cryptographically random number generation.

    Declaration
    public static void Shuffle<T>(Span<T> values)
    Parameters
    Type Name Description
    Span<T> values

    The span to shuffle.

    Type Parameters
    Name Description
    T

    The type of span.

    Implements

    IDisposable
    В этом разделе
    Наверх Generated by DocFX