#!/usr/bin/perl -s # coded by Oromis92 # <nicolabbi@libero.it> $key = shift or die "usage: perl $0 [-d] <key> [infile [>> outfile]]\n +"; while (<>) { $plain .= $_; } chomp($plain); @key = split //,$key; @plain = split //,$plain; @key = map(ord, @key); @S = 0..255; foreach $i (0..255) { $K[$i]=$key[$i%($#key+1)]; } sub KSA { $j=0; for ($i=0;$i<255;$i++){ $j = ($j + $S[$i] + $K[$i])%256; $temp = $S[$i]; $S[$i] = $S[$j]; $S[$j] = $temp; } } sub PRGA { $i = 0; $j = 0; for ($count=0;$count<length($plain);$count++) { $i = ($i + 1)%256; $j = ($j + $S[$i])%256; $temp = $S[$i]; $S[$i] = $S[$j]; $S[$j] = $temp; $t = ($S[$i] + $S[$j])%256; if (!$d) { $output = sprintf('%X', ($S[$t] ^ ord($plain[$count]))); if (length($output) % 2 == 0) { $result .= $output; } else { $output .= "0" ; $result .= $output; $output = ""; } } else { if ($count*2 < length($plain)) { $output = chr($S[$t] ^ (hex(substr($plain,($count*2),2 +)))); $result .= $output; $output = ""; } } } print "$result\n"; } KSA; PRGA;

In reply to ARC4 by Oromis92

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.