Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

incremental string generator - perl

Name: Anonymous 2008-10-09 14:27

real    1m21.853s
user    1m21.070s
sys     0m0.165s


This is on a 1.8ghz c2d. Incremental string generator from charset (999999 passes). Can anyone think of a more efficient way?

my $alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !?";

my $pass = "a";

for (my $i = 0; $i < 1000000; $i++) {
  $pass = nextPass($pass, $alpha);
}

sub nextPass {
  my ($in, $alpha) = @_;
  my @pass = split //, $in;
  my @set = split //, $alpha;
  my $current = $#pass;
  my $done = 0;
  while (!$done) {
    # is the current character the end of the set?
    if ($pass[$current] eq $set[$#set]) {
      # set the current character to the start of the set
      $pass[$current] = $set[0];
      # is the current character the beginning of the pass?
      if ($current == 0) {
        # add the start of the set to the end of the pass and finish
        push(@pass, $set[0]);
        $done = 1;
      } else {
        $current--;
      }
    } else {
      my $spot = index($alpha, $pass[$current]) + 1;
      $pass[$current] = $set[$spot];
      $done = 1;
    }
  }
  my $out = join "", @pass;
  return $out;
}

Name: Anonymous 2008-10-09 19:08

0,00s user
0,00s system
0,008 total



buffsize equ 10

section .bss
pass: resb buffsize

section .text
        global _start
_start:
        mov byte [pass], 30h
        mov r9, 0
        mov rcx, 999999
nextPass:
        mov r8, r9      ; current
.while:
        cmp byte [pass + r8], 'z'
        jne .else
.if:
        mov byte [pass + r8], 30h
        cmp r8, 0
        jne .over
        mov byte [pass + r8 + 1], 30h
        inc r9
        loop nextPass
        jmp away
.over:
        dec r8
        jmp .while
.else:
        inc byte [pass + r8]
        loop nextPass
away:
        mov rax, 4
        mov rbx, 1
        mov rcx, pass
        mov rdx, buffsize
        int 80h

        mov rax, 1
        xor rbx, rbx
        int 80h

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List