Example from crafted pseudorandom output.

Share your advanced PureBasic knowledge/code with the community.
User avatar
Azul
Enthusiast
Enthusiast
Posts: 109
Joined: Fri Dec 29, 2006 9:50 pm
Location: Finland

Example from crafted pseudorandom output.

Post by Azul »

Random() - Help files wrote:This command uses a pseudorandom number generator which is very fast and produces randomly looking output..

Code: Select all

Define string.s
Define temp.s

string = "iUhJypOdEbiOkTqmnPkDokIjYgDsKyOzxvtRfgjrigUguygiuYguyguYDdeeQuoonbhjJazsEzeZtretrERfyutiuygUygD"
string + "rsWBoiIUuigIUGTYDtcoinuOIoinuTfyttectytrciUyrctrecYTretreCtIuTTeiuBIuyIuyboiuybPOIUOiunOIybuytv"
string + "TRCYtYTvuytvuytUyRCExTerytvrUIytytviUTcrYTectretrxeRcytrcYtrcyTrCrWzxXxtrEcyTrvUytbUIybuiybiuyb"
string + "iutvcEEWrextrXrexctrvgunhiuoniuybviliUYTuytvuyTvuYTUVyrytexCTvbyuinopUIVtcytrCytrctyrvbiuonyioU"
string + "YVYRCtycrvbuyiuBYiuysiouOiuoIuviuvUytvuitycuytcTYercYtrvbuyiutyctrextreXTrcvtyrVytrcYtrCtyrcytc"
string + "rtycrYtrCYTrctyRcYTrxeEwxtrectyrcyTr"

RandomSeed(512)

For a=1 To 9
  temp+Mid(string,Random(512),1)
Next

Debug temp
"String" is not so random since I created it manually but hiding long strings into huge RandomData() dump is one way to hide text. Got idea from quite old trick to search words from common book to solve secret message.

Code: Select all

; Hello, World!
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Example from crafted pseudorandom output.

Post by Demivec »

Neat idea.

Here's a simple variation of my own:

Code: Select all

Define.s msg = "YvpmGbfye", temp
RandomSeed(512)

For a = 1 To Len(msg)
  temp + Chr(Asc(Mid(msg, a, 1)) ! Random(26))
Next

Debug temp
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Example from crafted pseudorandom output.

Post by Rook Zimbabwe »

from the PB 4.51 docs:
NOT MY CODE

Code: Select all

  *Key = AllocateMemory(16)    If OpenCryptRandom() And *Key
    CryptRandomData(*Key, 16)        Text$ = "Generated Key:"    For i = 0 To 15
      Text$ + " " + RSet(Hex(PeekB(*Key+i), #PB_Byte), 2, "0")    Next i     
        CloseCryptRandom()  Else    Text$ = "Key generation is not available"
  EndIf    MessageRequester("Example", Text$)
Don't forget about CryptRandom() and CryptRandomData() :mrgreen:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Post Reply