Created
August 17, 2015 19:18
-
-
Save anonymous/fa32c24a0d01f26b3922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'foobar' | perl sccrypt.pl | |
echo 'foobar' | perl sccrypt.pl | perl scdecrypt.pl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use warnings; | |
use strict; | |
use MIME::Base64 qw(encode_base64); | |
my @stream = split //, do { local $/; <> }; | |
my @rand = map { int rand 99 } (1) x 5; | |
my $out = ''; | |
my $i = 0; | |
my @encrypted; | |
while ( $i < @stream ) { | |
push @encrypted, unpack( 'C', $stream[$i] ) ^ $rand[ $i++ % @rand ]; | |
} | |
print encode_base64( pack( 'I5C*', @rand, @encrypted ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use warnings; | |
use strict; | |
use MIME::Base64 qw(decode_base64); | |
my $in = do { local $/; <> }; | |
my ( @rand, @encrypted ); | |
( @rand[ 0 .. 4 ], @encrypted ) = unpack( 'I5C*', decode_base64($in) ); | |
my $i = 0; | |
my @decrypted; | |
while ( $i < @encrypted ) { | |
push @decrypted, pack( 'C', $encrypted[$i] ^ $rand[ $i++ % @rand ] ); | |
} | |
print join '', @decrypted; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment