Tag Archives: random

Select random objects from an array in C#

This example builds a generic extension method that lets you easily select random objects from an array. The following code shows the extension method and the RandomTools class that defines it. public static class RandomTools { // The Random object … Continue reading

Posted in algorithms, arrays, mathematics, variables | Tagged , , , , , , , , , , , , | Leave a comment

Use VBA code to pick random cells from the currently selected cells in an Excel workbook

This example shows how you can use VBA code to pick random cells in an Excel workbook. Sooner or later, many programmers need to write code to control another application such as the Microsoft Office applications, either for their own … Continue reading

Posted in Excel, VBA | Tagged , , , , , , , , , , | Leave a comment

Make a password manager in C#

Before I discuss this example, let me make a disclaimer and say that I can’t guarantee this application’s performance. I think it is secure but for something as important as passwords you need to merely use this program as an … Continue reading

Posted in algorithms, cryptography, mathematics, registry, system | Tagged , , , , , , , , , , , , , , , , , , , | 4 Comments

Use cryptographic methods to generate random passwords in C#

Lately I’ve gotten more than a little tired of having to generate random passwords that obey all sorts of stupid rules for various web sites. Who cares if I use a strong password on a web site that just sends … Continue reading

Posted in algorithms, cryptography, mathematics, system | Tagged , , , , , , , , , , , , , , , , , , | 1 Comment

Use a cryptographic random number generator in C#

The Random class generates random numbers, but they aren’t cryptographically secure. What does “cryptographically secure” mean? It means that an attacker, after seeing a series of random numbers that you generate, cannot predict the next one with any success. This … Continue reading

Posted in algorithms, cryptography, mathematics | Tagged , , , , , , , , , , | 9 Comments

Randomize arrays in C#

This example builds a Randomizer class that lets you randomize arrays. It provides a generic Randomize method that randomizes an array containing any kind of data. The following code shows the class. public class Randomizer { public static void Randomize<T>(T[] … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | 7 Comments