Question

I have a line of code in a piece of C# I'm analyzing.

`random.next(0xf4240, 0x98967f).ToString();'

I know the command line is generating a number between the specified ranges and returning it as a string. Whats a little odd to me is the '0xf' and the '0x#####f'

I looked up that the 0xf is supposed to return a nybbie but I'd realy like to get an idea of what the raw values would be. Any help would be great.

Thanks.

Was it helpful?

Solution

In C#, 0x is used as prefix to represent hexadecimal integer literals. See the spec

In your case, f4240 and 98967f are just two integers represented in hexadecimal system.

Update: As @codesparkle has stated they represent 1000000 and 9999999 respectively

OTHER TIPS

The prefix 0x is how you specify hexadecimal values in C# and a number of other languages. It's my belief that hexadecimal can only specify integer values, although I may be wrong.

In your case, 0xf4240 is the same as F4240 in hexadecimal, or a 1.000.000 in decimal. 0x98967f is the same as 9.999.999 in decimal.

One thing, this code was obviously obfuscated on purpose, which is baaaad. There seems to be no need to provide those values in hexadecimal.

The command line isn't generating anything - your C# application (which happens to output to the command line) is calculating a pseudo-random number between 1000000 and 9999999 (you are passing in the hex representations).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top