Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: My Perl Obfuscator

by jwkrahn (Abbot)
on Jan 11, 2024 at 21:03 UTC ( [id://11156891]=note: print w/replies, xml ) Need Help??


in reply to My Perl Obfuscator

sub ReadTheEntireFile { my $F = defined $_[0] ? $_[0] : ''; $F =~ tr`<>*?\"\|\x00-\x1F``d; # Remove illegal characters. ... sub CreateFile { defined $_[0] or return 0; my $F = shift; # Remove illegal characters from file name: $F =~ tr`<>*?\"\|\x00-\x1F``d;
$ perl -le' my $x = join "", map chr, 0 .. 255; ( my $y = $x ) =~ tr`<>*?\"\|\x00-\x1F``d; use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper $_ for $x, $y; ' $VAR1 = "\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\3 +0\31\32\e\34\35\36\37 !\"#\$%&'()*+,-./0123456789:;<=>?\@ABCDEFGHIJKL +MNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\2 +03\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\22 +4\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245 +\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\ +267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\3 +10\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\33 +1\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352 +\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\ +374\375\376\377"; $VAR1 = " !#\$%&'()+,-./0123456789:;=\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ +_`abcdefghijklmnopqrstuvwxyz{}~\177\200\201\202\203\204\205\206\207\2 +10\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\23 +1\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252 +\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\ +274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\3 +15\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\33 +6\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357 +\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377";

Your code removes control characters and certain punctuation but does not remove non-ASCII characters. Is this intentional?

Naked blocks are fun! -- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re^2: My Perl Obfuscator
by harangzsolt33 (Chaplain) on Jan 11, 2024 at 22:59 UTC
    "Your code removes control characters and certain punctuation but does not remove non-ASCII characters. Is this intentional?"

    Well, I really didn't have to include that line, but I did anyway just to be consistent. If I'm going to disallow certain characters in a file name when reading, then I would do the same for creating a file just to be consistent. The reason I chose to ban these characters is because they may be used for bad purposes when reading a file, and they're illegal anyway if you look at the file system specs. The NTFS and FAT file systems disallow creating files with characters 0x00-0x1F and you also can't have files that include: > < * ? | " but it's ok to have a file which contains characters from the extended ASCII chart (0x80-0xFF).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11156891]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found