forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Random password generator - pure VDS

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Wed Feb 27, 2002 10:18 am    Post subject: Random password generator - pure VDS Reply with quote

The subjects says it all - it's really nothing but a way to generate a list of
passwords in VDS 3 without using external DLLs. As "usual" the @datetime()
function is used to get an initial random number. It can be done much
simpler by using a WAIT command to let the @datetime output change in
each pass, but a list of just a few hundred password strings will take a
loooong time to generate. So I let VDS run at full speed and check for the
inevitable doublets.

Code:

  option decimalsep,"."

  REM Set variables here
  REM First the number of passwords to generate
  %%count = 500
  REM Then the length of each password
  %%passlength = 12
  REM A list of chars to build the passwords - here numbers are tripled to get more numbers in
  REM passwords. Quite a long string (but less than 100) is preferred to keep from getting too
  REM many position errors later
  %%chars = "0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
  REM output filename
  %%filename = gen-pass.txt

  LIST create,1
  %%countlines = 1
  REPEAT
    %%password = ""
    %a = 1
   %b = 1
    REPEAT
     REM Go ahead, get a random number - the idea for using @ext(@datetime()) is Garrett's
      %%seed = @ext(@datetime())
      REM Do some math on it to randomize between passes
     %%num = @fmul(@fmul(%%seed,%a),%%countlines)
     REM Get a position to extract a char from the list of available chars
      %%pos = @substr(%%num,@fsub(@len(%%num),1),@len(%%num))
      GOSUB checkrandom
     REM Build a password string
      %%nextchar = @substr(%%chars,%%pos,)
      %%password = %%password%%nextchar
      %a = @succ(%a)
    UNTIL @greater(%a,%%passlength)
   GOSUB no-dubl
  UNTIL @greater(%%countlines,%%count)
  LIST savefile,1,%%filename
  LIST close,1
  SHELL OPEN,%%filename
  WAIT 2
  REM Well, if you want to keep the file, REM out the next line
  FILE DELETE,%%filename
  STOP

REM ############# SUBs #################

:checkrandom
  REM Check for invalid values - fix any found
  IF @zero(%%pos)
    %%num = @fmul(%a,@ext(@datetime()))
    %%pos = @substr(%%num,@fsub(@len(%%num),2),@pred(@len(%%num)))
    GOTO checkrandom
  END
  IF @greater(%%pos,@len(%%chars))
    %%pos = @format(@div(%%pos,@sum(%a,1)),2.0)
    GOTO checkrandom
  END
  EXIT

:no-dubl
REM Check for doublets
IF @greater(@count(1),0)
  LIST seek,1,0
END
IF @match(1,%%password)
  REM Do case-sensitive matching, if case-sense off then remove EXACT
  IF @equal(@item(1),%%password,EXACT)
    REM If doublet found try to manipulate the string a bit to make a unique one
    %%buffer = @substr(%%password,%b,)
   %%password = @strdel(%%password,%b,)
   %%password = @strins(%%password,11,%%buffer)
    %b = @succ(%b)
     if @equal(%b,%%passlength)
         %b = 1
     end
  GOTO no-dubl
  END
ELSE
  LIST add,1,%%password
  %%countlines = @succ(%%countlines)
END
EXIT


Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Sun Jan 05, 2003 8:42 pm    Post subject: Reply with quote

Here's a less sophisticated one in pure VDS. Had fun with this Dread. Wink
__________________________________________________________________________________________________________________________
Code:

rem -- 72 chars. Replace A-Z with a-z if using all lower case.
rem -- Will only use same char once, whether upper or lower.
rem -- NOTE: Not for passwords larger than 28 chars.
%%chars = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"

OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Password Generator",-1,0,200,80
  DIALOG ADD,TEXT,T1,9,5,,,"Password Length"
  DIALOG ADD,EDIT,E1,5,90,50,24,"10"
  DIALOG ADD,BUTTON,Create,5,145,50,24,
  DIALOG ADD,EDIT,E2,35,5,190,24
  DIALOG ADD,STATUS,Stat
DIALOG SHOW

:EVLOOP
  WAIT EVENT
  goto @event()

:CreateBUTTON
  if @greater(@dlgtext(E1), 28)
     DIALOG SET, E1, 28
  end
  %s = ""
  REPEAT
    %n = @ext(@datetime())
    if @greater(@len(%n), 1)
       %n = @substr(%n, @pred(@len(%n)), @len(%n))
       if @greater(73, %n)
          if @equal(@pos(@substr(%%chars, %n), %s), 0)
             %s = %s@substr(%%chars, %n)
             DIALOG SET, E2, %s
             DIALOG SET, Stat, Length = @len(%s)
          end
       end
    end
  UNTIL @greater(@len(%s), @pred(@dlgtext(E1))) @event()
  goto EVLOOP

:CLOSE
  EXIT


Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon Jan 06, 2003 7:43 am    Post subject: Reply with quote

He-he. That's you in a nutshell, Mac - when you spot a chance to do a small outside-the-box routine,
you probably don't get a wink of sleep until you got it nailed down.
Wink

Well, I know the feeling myself. I'm pinned down in a blizzard here, so perhaps I'll start making some
never-to-be-used little routines or even go about benchmarking some mouseovers like NodNarb Laughing Laughing

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group