Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

English to h4x0r translator

by Trag (Monk)
on Apr 09, 2004 at 23:17 UTC ( [id://344056]=CUFP: print w/replies, xml ) Need Help??

1 |-|0p3 yuo d00dz 1ik3 17!

#!/lusr/bin/perl use warnings; use strict; print "File to make l337?\n!!!"; my $file=<STDIN>; open (FILE, "<$file") || die "Couldn't find the file, sorry: $!\n"; open (LEET, ">leeted.txt") || die "Couldn't create file: $!"; while (<FILE>) { s/e/3/ig; s/t/7/ig; s/h/|-|/ig; s/i/1/ig; s/l/1/ig; s/a/4/ig; s/s/5/ig; s/o/0/ig; print LEET; } close FILE; close LEET;


4ny h31p w17h teh tr4n514710n 45p3c75 w0u1d b3 4ppr3c14t3d, 4s w0u1d 4ny 5ugg35710n5.

#############################################
print "Just another iconoclastic Perl hacker";

Replies are listed 'Best First'.
Lingua::31337 - P3RL M0DU1E 7O c0NVer7 7ext 7O C0o1 741k
by PodMaster (Abbot) on Apr 10, 2004 at 06:35 UTC
    use Lingua::31337 'text231337'; $Lingua::31337::LEVEL = 9; die text231337 "Hi. I like CPAN :)$/"; __END__ H1. 1 1IK0 cPAn :)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: English to h4x0r translator
by parv (Parson) on Apr 10, 2004 at 05:26 UTC

    I find myself needing a reverse translator. I think adding a option, say -r, & putting the translations in a hash would allow that. Something like the untested code below ...

    my %map = ( 'a' => '4' , 'e' => '3' , 'h' => '|-|' , 'i' => '1' , 'l' => '1' , 'o' => '0' , 's' => '5' , 't' => '7' ) ; # $reverse is set by some other means @map{ values %map } = keys %map if $reverse ; while ( <DATA> ) { foreach my $k ( keys %map ) { s/ $k / $map{$k} /giex; } print; }

      An update of tested code to previously untested code...

      #!/usr/local/bin/perl use warnings; use strict; # An naive attempt to cross translate between '3133+' speak & readabl +e # enough English. # # English conversion is bound to have gross spelling errors. No doub +t, # it sure could use some additions in $letter, $group and $word. # Spelling check and soundex related modules could also be brought in # to produce even more readable language. # Set to a true value if converting from '3133+' to 'elite' my $reverse = 1; # Mapping our ( $word , $group , $letter ); if ( $reverse ) { transform_hash( $_ ) foreach $word , $group , $letter; } while ( my $line = <> ) { replace_word( $line , $word ); foreach my $map ( $group , $letter ) { foreach my $k ( keys %{$map} ) { foreach my $el ( @{ $map->{$k} } ) { $line =~ s/\Q$k/$el/gi; } } } print $line; } BEGIN { our $word = { 'hacker' => [ qw( haxor ) ] , 'for' => [ qw( 4 ) ] }; our $group = { 'orn' => [ qw( r0n 0rn ) ] }; our $letter = { 'a' => [ qw( 4 @ ) ] , 'c' => [ qw/ ( / ] , 'd' => [ qw/ |) / ] , 'e' => [ qw( 3 ) ] , 'h' => [ qw( |-| ) ] , 'i' => [ qw( 1 ) ] , 'l' => [ qw( 1 |_ ) ] , 'm' => [ qw( |V| |\\/| ) ] , 'n' => [ qw( |\\| ) ] , 'o' => [ qw( 0 ) ] , 's' => [ qw( 5 ) ] , 't' => [ qw( 7 + ) ] , 'w' => [ qw( \\/\\/ ) ] } ; } sub replace_word { my ($line , $map) = @_; foreach my $k ( keys %{$map} ) { foreach my $word ( @{ $map->{$k} } ) { # Needs better right word boundary than '\s' or '\b'. For examp +le, # it would fail to convert '4' at the end of a sentence to 'for' +. $line =~ s/ \b $k (?=\s) /$word/gix; } } $_[0] = $line; } sub transform_hash { my $hash = shift; foreach my $k ( keys %{$hash} ) { foreach my $v ( @{ $hash->{$k} } ) { $hash->{$v} = [$k]; } delete $hash->{$k}; } }

      Input: 4ny h31p w17h the tr4n514710n 45p3c75 w0u1d b3 4ppr3c14t3d, 4s w0u1d 4ny 5ugg35710n5.
      Output: any heip with the transiation aspects wouid be appreciated, as wouid any suggestions.
      Input: 45 \/\/45 4|_r34|)y p01|\|+3d @u7, +|-|3Re 15 @ |\/|0|)u1e +h@t c4|\| do0 7h1s 4 y0o. T|-|Er3 1s |\/|u(h m0r3 y0u c@|\| |)0 +o t3X+ t|-|4n 51mp73 r3p7@ce|\/|en+5.
      Output: as was already pointed aut, theRe is a moduie that can doo this for yoo. ThEre is much more you can do to teXt than simpte reptacements.

        - Parv
      
Re: English to h4x0r translator
by injunjoel (Priest) on May 07, 2004 at 23:20 UTC
    100k5 900d 2 m3.
Re: English to h4x0r translator
by Anonymous Monk on Apr 10, 2004 at 10:25 UTC

    45 \/\/45 4|_r34|)y p01|\|+3d @u7, +|-|3Re 15 @ |\/|0|)u1e +h@t c4|\| do0 7h1s 4 y0o. T|-|Er3 1s |\/|u(h m0r3 y0u c@|\| |)0 +o t3X+ t|-|4n 51mp73 r3p7@ce|\/|en+5.

      As was already pointed out, there is a module that can do this for you. There is much more you can do to text than simple replacements.

      Such as inconsistent transliteration, which your remarks show pretty well, e.g. '15' and '1s'.

      --
      Allolex

        om6s t3h h4x!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://344056]
Approved by Paulster2
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found