-
Notifications
You must be signed in to change notification settings - Fork 33
/
math_expr_encoder.pl
executable file
·35 lines (31 loc) · 1.05 KB
/
math_expr_encoder.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl
# Daniel "Trizen" Șuteu
# License: GPLv3
# Date: 14 April 2012
# https://github.com/trizen
@ARGV = @ARGV ? (@ARGV) : ($0);
foreach my $file (grep { -f } @ARGV) {
open my $fh, '<', $file or next;
my $s = '';
while (1) {
my $i = ord(getc($fh) // last);
while (1) {
my $f = int rand $i;
my $l = int rand $i * 2;
if (($f | $l) == $i) { $s .= "$f|$l," => last }
if (($f * $l) == $i) { $s .= "$f*$l," => last }
if (($l >> $f) == $i) { $s .= "$l>>$f," => last }
if (($f << $l) == $i) { $s .= "$f<<$l," => last }
if (($l << $f) == $i) { $s .= "$l<<$f," => last }
if (($f**$l) == $i) { $s .= "$f**$l," => last }
if (($l**$f) == $i) { $s .= "$l**$f," => last }
if (($f + $l) == $i) { $s .= "$f+$l," => last }
if (($l - $f) == $i) { $s .= "$l-$f," => last }
if (($f ^ $l) == $i) { $s .= "$f^$l," => last }
}
}
close $fh;
print <<"EOT";
print chr for $s;
EOT
}