lundi 19 août 2019

In C, how can I generate a random string from a seed?

I want to make a way to generate a seemingly random string from a random number in the form of a seed. But if I use the same seed I get the same result. I need a function that will generate large random strings from a number. A string with a thousand letters, from a number. Any number, no matter how simple. But if I use the same number, I will get the same string. For example, one would give me a 1000 long string of random looking numbers. 2 would give a whole different 1000 character long string. But if I give 1 again, I would get the same one.

I am not allowed to have a switch statement like:

switch(n) {
    case 1:
        return "943hfj9a0fw9ubhi0rq746gyheuipoyferewoirt ...";
        break;
    case 2:
        return "984h29uu384gu2hj34982h4m234uh2349238u9uh ...";
        break;
    ...
}

Does anyone know how to do this?




Aucun commentaire:

Enregistrer un commentaire