The same random numbers

Discussion in 'Questions (Windows Mobile)' started by LineCutter, Oct 14, 2008.

  1. LineCutter

    LineCutter Active Member Licensed User

    I might have missed this, but is there a way to specify a seed value to the rnd() function so that the same pseudo-random sequence is generated each time?
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can do it with the Door library:
    Sub Globals
    'Declare the global variables here.

    End Sub

    Sub App_Start
    0,75,"System.Int32"'Set the seed value
    End Sub

    Sub MyRnd(Minimum, Maximum)
    Return Random.RunMethod3("Next",Minimum,"System.Int32",Maximum,"System.Int32")
    End Sub

    Attached Files:

  3. LineCutter

    LineCutter Active Member Licensed User

    Thanks. That helps me create a password for the crypto question that agraham helped me with. Since it won't be physically present in the code it'll be that little bit harder for the casual hacker to bypass.
    For i = 0 To 64
  4. agraham

    agraham Expert Licensed User

    That's a good idea! Why not take it a bit further and generate the characters directly? In this case printable ASCII ones. As an aside why 65 characters in n?

    For i = 0 To 64
  5. LineCutter

    LineCutter Active Member Licensed User

    The code was from an "obfuscate as hex values" routine from a test program, hence the limited characters used.

    As for 65 values... well I'm clearly not a coder yet! :sign0148:
    (Although it was an arbitrary number the intention was for 64 characters, regardless of the fact that they would then go through the MD5 -> DES.key processing you help me with a few days back)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice