'Hexadecimal Loops in C#
My goal was to get a 3DES password and for that im missing the last 6 digits.
for (int i = 0; i <= 16777215; i++)
{
string hexValue = i.ToString("X").PadLeft(6, '0');
}
Solution 1:[1]
You could just get the maximum number in your set of hexadecimals which goes from [0,FFFFFF] in decimal the set goes from [0, 16777215]
for(int i = 0; i <= 16777215; i++) {
string hexValue = i.ToString("X");
// your logic goes here...
}
Solution 2:[2]
This should do it:
var allHexadecimals = Enumerable.Range(0, 0xFFFFFF + 1)
.Select(i => i.ToString("X").PadLeft(6, '0'));
Solution 3:[3]
You can actually convert directly to Hex from c#, check out this article:
e.g. for(int i = 0x0; i < 0xff;i+=0x01) {Console.WriteLine(iConsole.WriteLine(value.ToString("X"));}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | raven |
Solution 2 | |
Solution 3 |