Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w $key=0; #Initialize variables. $updown=0; $i=0; @arrdone=(0,0,0,0,0,0,0,0); print "Enter passphrase: "; $phrase=<STDIN>; chomp $phrase; @letters = split //,$phrase; foreach $CHAR (@letters) { #Use phrase to create random seed $newbits=ord($CHAR); $modulo = $newbits % 10; if ($updown == 0) { if ($key < 0){$key*=-1;} $key=$key*($modulo+1); $key+=$newbits; if ($key>4294967294){$updown=1;} } if ($updown == 1) { $key=$key/($modulo+1)-($key%($modulo+1)/($modulo+1)); $key-=$newbits; if ($key<0){$updown=0;} } } srand $key; while(<STDIN>) { chomp; @inputchars = split //; foreach $CHAR (@inputchars){ $charnum=ord($CHAR); $oldt=$charnum; for (0..8) { #Translate the input char into binary $t = $charnum % (2**$_); if($t==$oldt) { $binarr[8-$_]=0; }else {$binarr[8-$_]=1;} $oldt=$t; } while ($i<8) { #Assemble the key bit vector. $randout=rand(8)%8; if ($arrdone[$randout]==0) { $shifter[$i]=$randout; $arrdone[$randout]=1; $i++; } } for(0..7) { #Assemble the scrambled bit vector. if ($binarr[$_]==1) { $outchar[$shifter[$_]] = 1; } else {$outchar[$shifter[$_]] =0;} } for(0..7) { #Rejoin the new bits to an ord if ($outchar[$_]==1) { $sum+=2**(7-$_); } } $och= chr($sum); #Print the char. print $och; $i=0; #Reset variables $sum=0; for(0..7){ $outchar[$_]=0; $arrdone[$_]=0; $shifter[$_]=0; } } }

In reply to Wombat's Bit Scrambler by wombat

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2023-09-26 23:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found