Create Random number
-
How to create a random number not only using the MFC function but using the current time of generation and the mouse position? It should be impossible to crack /\|-||\/|/\|)
-
hey mr Halawlaws, i wonder if you are not using CodeProject because you are too tired to search the MSDN[^]...
#include <stdlib.h>
srand((unsigned)time(NULL));
int i = rand();
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
toxcct wrote: i wonder if you are not using CodeProject because you are too tired to search the MSDN[^]... no not true and mouse position? /\|-||\/|/\|)
-
toxcct wrote: i wonder if you are not using CodeProject because you are too tired to search the MSDN[^]... no not true and mouse position? /\|-||\/|/\|)
what about the mouse position ? if you use it, it will not be random anymore ...
Maximilien Lincourt Your Head A Splode - Strong Bad
-
what about the mouse position ? if you use it, it will not be random anymore ...
Maximilien Lincourt Your Head A Splode - Strong Bad
-
convert the random number to string and split into two..make them again as int. multiply one part of the number with Cpoint's x and others's with another (y + another Random number) ..he he :confused: vivek
-
yes because if u open the dialog and move it u will have different position of mouse also on each different computer it will be different /\|-||\/|/\|)
so ? what exactly you want to do ? ( besides the random numbers ) .
Maximilien Lincourt Your Head A Splode - Strong Bad
-
so ? what exactly you want to do ? ( besides the random numbers ) .
Maximilien Lincourt Your Head A Splode - Strong Bad
-
The software allow users to create random serial number for there companies based on the serial number of the product. This random number is sold later if a certain client need to enable something in his device. /\|-||\/|/\|)
why do you want to use the mouse position ? just generate the number with srand ( or rand, or some other methods ) and be done with it.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
why do you want to use the mouse position ? just generate the number with srand ( or rand, or some other methods ) and be done with it.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
The software allow users to create random serial number for there companies based on the serial number of the product. This random number is sold later if a certain client need to enable something in his device. /\|-||\/|/\|)
You'd be better off using a GUID for this. You can use the guidgen.exe utility, or use
CoCreateGuid()
if you need it at run-time. The algorithm is already established, plus you cannot achieve true randomness withrand()
, or any other function for that matter.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
i need to complicate it so the user cannot use the usual function of C++ to generate such a code /\|-||\/|/\|)
The odds of that happening would be 1 in 32,768.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
i need to complicate it so the user cannot use the usual function of C++ to generate such a code /\|-||\/|/\|)
if the user is smart enough to watch your code call srand, he's smart enough to watch your code get the current mouse position. Cleek | Image Toolkits | Thumbnail maker
-
How to create a random number not only using the MFC function but using the current time of generation and the mouse position? It should be impossible to crack /\|-||\/|/\|)
Hello In my opinion, a better way to do what you need is to use one of the random number generator routines in "NUMERICAL RECIPIES": http://www.library.cornell.edu/nr/cbookcpdf.html Scroll down to Ch. 7 in that page and you'll find a lot of algorithms that will be by far better you can come up using only your machine generator. You'll still need it, but the algorithms provide better "randomness" in your numbers and they are sorted by the way you need them to have certain statistical distributions. If you need them to have equal probabilities, then use the ran2 algorithm. This code is an implementation of it:
seed = 0; srand (time(NULL)); rand(); seed = rand(); return ran2(seed);
The return number is a uniform random deviate between 0 and 1. If you need integers just multiply your number as needed and take the integer. Cheers