| echo 'foobar' | perl sccrypt.pl | |
| echo 'foobar' | perl sccrypt.pl | perl scdecrypt.pl |
| 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 ) ); |
| 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