Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ROT13 obfuscator

42 views
Skip to first unread message

Mike Sanders

unread,
May 5, 2017, 3:05:22 PM5/5/17
to
Just seeing for myself what can be accomplished using batch.
Its certainly a terse language but honestly pretty powerful...


@echo off & setlocal enabledelayedexpansion

:: ROT13 obfuscator for trivial encryption
:: Michael Sanders - 2017
:: https://busybox.hypermart.net
::
:: example: rot13.cmd Rire abgvpr cflpuvpf arire jva gur ybggrel?

:setup

set str=%*
set buf=%str%
set len=0

:getlength

if not defined buf goto :start
set buf=%buf:~1%
set /a len+=1
goto :getlength

:start

if %len% leq 0 (echo rot13: zero length string & exit /b 1)
set num=0
set r13=
set abc=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
set nop=NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm5678901234

:rot13

for /l %%x in (!num!,1,%len%-1) do (
set log=0
for /l %%y in (0,1,61) do (
if "!str:~%%x,1!"=="!abc:~%%y,1!" (
call set r13=!r13!!nop:~%%y,1!
set /a num=%%x+1
set /a log+=1
if !num! lss %len% goto :rot13
)
)
if !log!==0 call set r13=!r13!!str:~%%x,1!
)

:done

echo !r13!
endlocal & exit /b 0



--
later on,
Mike

https://busybox.hypermart.net

JJ

unread,
May 5, 2017, 8:32:54 PM5/5/17
to
On Fri, 5 May 2017 19:02:05 -0000 (UTC), Mike Sanders wrote:
> Just seeing for myself what can be accomplished using batch.
> Its certainly a terse language but honestly pretty powerful...

I wonder which programming language can't do string manipulation... Prolog?

Mike Sanders

unread,
May 5, 2017, 10:00:25 PM5/5/17
to
JJ <jj4p...@vfemail.net> wrote:

> I wonder which programming language can't do string manipulation... Prolog?

You know I've never used Prolog JJ. But funny you should mention
it as I've read two articles this week about it.

Had to checkout the Wikipedia page for Prolog after reading your reply,
says its Turing complete:

<https://en.wikipedia.org/wiki/Prolog>

pro...@berkeley.edu

unread,
May 6, 2017, 3:30:02 AM5/6/17
to
On Friday, May 5, 2017 at 12:05:22 PM UTC-7, Mike Sanders wrote:
> Just seeing for myself what can be accomplished using batch.
> Its certainly a terse language but honestly pretty powerful...
>
>

Nice, Mike!

Here's some more fun and games for your enjoyment. Win7Pro.

c:\work>type MyFunnyValentine.txt

My funny valentine,
Sweet comic valentine,
You make me smile with my heart.
Your looks are laughable,
Unphotographable,
Yet you're my favorite work of art.

Is your figure less than Greek?
Is your mouth a little weak?
When you open it to speak,
Are you smart?

But don't change a hair for me,
Not if you care for me.
Stay, little valentine, stay.
Each day is Valentine's Day.

c:\work>xlatefile low2up MyFunnyValentine.txt

MY FUNNY VALENTINE,
SWEET COMIC VALENTINE,
YOU MAKE ME SMILE WITH MY HEART.
YOUR LOOKS ARE LAUGHABLE,
UNPHOTOGRAPHABLE,
YET YOU'RE MY FAVORITE WORK OF ART.

IS YOUR FIGURE LESS THAN GREEK?
IS YOUR MOUTH A LITTLE WEAK?
WHEN YOU OPEN IT TO SPEAK,
ARE YOU SMART?

BUT DON'T CHANGE A HAIR FOR ME,
NOT IF YOU CARE FOR ME.
STAY, LITTLE VALENTINE, STAY.
EACH DAY IS VALENTINE'S DAY.


c:\work>set phrase=Iwt fjxrz qgdlc udm yjbeh dktg iwt apon sdv

c:\work>for /l %i in (1,1,26) do @xlate rot%i "%phrase%"
"Jxu gkysa rhemd ven zkcfi eluh jxu bqpo tew"
"Kyv hlztb sifne wfo aldgj fmvi kyv crqp ufx"
"Lzw imauc tjgof xgp bmehk gnwj lzw dsrq vgy"
"Max jnbvd ukhpg yhq cnfil hoxk max etsr whz"
"Nby kocwe vliqh zir dogjm ipyl nby futs xia"
"Ocz lpdxf wmjri ajs ephkn jqzm ocz gvut yjb"
"Pda mqeyg xnksj bkt fqilo kran pda hwvu zkc"
"Qeb nrfzh yoltk clu grjmp lsbo qeb ixwv ald"
"Rfc osgai zpmul dmv hsknq mtcp rfc jyxw bme"
"Sgd pthbj aqnvm enw itlor nudq sgd kzyx cnf"
"The quick brown fox jumps over the lazy dog"
"Uif rvjdl cspxo gpy kvnqt pwfs uif mbaz eph"
"Vjg swkem dtqyp hqz lworu qxgt vjg ncba fqi"
"Wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj"
"Xli uymgo fvsar jsb nyqtw sziv xli pedc hsk"
"Ymj vznhp gwtbs ktc ozrux tajw ymj qfed itl"
"Znk waoiq hxuct lud pasvy ubkx znk rgfe jum"
"Aol xbpjr iyvdu mve qbtwz vcly aol shgf kvn"
"Bpm ycqks jzwev nwf rcuxa wdmz bpm tihg lwo"
"Cqn zdrlt kaxfw oxg sdvyb xena cqn ujih mxp"
"Dro aesmu lbygx pyh tewzc yfob dro vkji nyq"
"Esp bftnv mczhy qzi ufxad zgpc esp wlkj ozr"
"Ftq cguow ndaiz raj vgybe ahqd ftq xmlk pas"
"Gur dhvpx oebja sbk whzcf bire gur ynml qbt"
"Hvs eiwqy pfckb tcl xiadg cjsf hvs zonm rcu"
"Iwt fjxrz qgdlc udm yjbeh dktg iwt apon sdv"


C:\work>xlatefile Aa-Zz2Gleek MyFunnyValentine.txt > MFV.gleek

C:\work>type MFV.gleek
Ÿ ² ™™ ˜‹# ™ Š™ ,
¦Ž › ®Š› ˜‹# ™ Š™ ,
®‹€ ® ®Š# ŽŠ ® ‹ .
# € ‹ #‹ œ ‹§# ,
ž™¨ œ ‹¨ ‹§# ,
' ® ²‹˜ Š Ž € ² ‹ .

š ²Šœ # ‹™ Í €?
š ® ‹ #Š # Ž ‹€?
­ ™ ¨ ™ Š ¨ ‹€,
¤ ®‹ ?

¡ ™' › ‹™œ ‹ ‹Š ² ® ,
Î Š² ›‹ ² ® .
¦ ‹ , #Š # ˜‹# ™ Š™ , ‹ .
—‹› ¡‹ Š ú‹# ™ Š™ ' ƒ‹ .

C:\work>xlatefile Gleek2Aa-Zz MFV.gleek
My funny valentine,
Sweet comic valentine,
You make me smile with my heart.
Your looks are laughable,
Unphotographable,
Yet you're my favorite work of art.

Is your figure less than Greek?
Is your mouth a little weak?
When you open it to speak,
Are you smart?

But don't change a hair for me,
Not if you care for me.
Stay, little valentine, stay.
Each day is Valentine's Day.



==========begin "c:\wyl2016\xlatefile.cmd" ==========
01. @echo off
02. set infile="%~2"
03. set mode=%1
04.
05. for /f "tokens=1* skip=2 delims=]" %%B in (
06. 'find /v /n "%~n0 %time% for a %date% today" "%~2"'
07. ) do (
08. set "line=%%C "
09. call xlate %mode% line
10. )
11. goto :EOF
==========end "c:\wyl2016\xlatefile.cmd" ==========

==========begin "c:\wyl2016\xlate.cmd" ==========
01. @echo off
02. setlocal
03. set mode=%1
04. set input=%2
05. if /i %mode%==low2up (
06. set /p from=<%WylburRoot%\data\lower.dat
07. set /p to=<%WylburRoot%\data\upper.dat
08. set size=25
09. )
10. if /i %mode%==up2low (
11. set /p from=<%WylburRoot%\data\upper.dat
12. set /p to=<%WylburRoot%\data\lower.dat
13. set size=25
14. )
15. if /i %mode%==Aa-Zz2gleek (
16. set /p from=<%WylburRoot%\data\Aa-Zz.tbl
17. set /p to=<%WylburRoot%\data\Gleek.tbl
18. set size=52
19. )
20. if /i %mode%==gleek2Aa-Zz (
21. set /p from=<%WylburRoot%\data\Gleek.tbl
22. set /p to=<%WylburRoot%\data\Aa-Zz.tbl
23. set size=52
24. )
25. if /i %mode%==Aa2Zz (
26. set /p from=<%WylburRoot%\data\Aa-Zz.tbl
27. set /p to=<%WylburRoot%\data\zZ-aA.tbl
28. set size=52
29. )
30. if /i %mode%==zZ2aA (
31. set /p from=<%WylburRoot%\data\zZ-aA.tbl
32. set /p to=<%WylburRoot%\data\Aa-Zz.tbl
33. set size=52
34. )
35. if /i %mode:~0,3%==rot (
36. call :xrottbl %mode%
37. set size=52
38. )
39. if defined %input% set input=!%input%!
40. set input=%input:"=`%
41. set $O=
42. :Next_char
43. set C=%input:~0,1%
44. set input=%input:~1%
45. set out=
46. for /l %%i in (0,1,%size%) do (
47. if "!from:~%%i,1!"=="%C%" (
48. set out=!to:~%%i,1!
49. goto :found
50. )
51. )
52. if not defined out set out=%C%
53. :found
54. set $O=%$O%%out%
55. if defined input goto :Next_char
56. set $O=%$O:`="%
57. echo/%$O%
58. endlocal & set %2=%$O%&goto :EOF
59.
60. :xrottbl
61. set /p from=<%WylburRoot%\data\Aa-Zz.tbl
62. set val=%1
63. set /a val = %val:rot=% * 2
64. call set to=%%from:~%val%%%%%from:~0,%val%%%
65. goto :EOF
==========end "c:\wyl2016\xlate.cmd" ==========

==========begin "c:\wyl2016\data\lower.dat" ==========
1. abcdefghijklmnopqrstuvwxyz
==========end "c:\wyl2016\data\lower.dat" ==========

==========begin "c:\wyl2016\data\upper.dat" ==========
1. ABCDEFGHIJKLMNOPQRSTUVWXYZ
==========end "c:\wyl2016\data\upper.dat" ==========

==========begin "c:\wyl2016\data\Aa-Zz.tbl" ==========
1. AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz
==========end "c:\wyl2016\data\Aa-Zz.tbl" ==========

==========begin "c:\wyl2016\data\zZ-aA.tbl" ==========
1. zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA
==========end "c:\wyl2016\data\zZ-aA.tbl" ==========

==========begin "c:\wyl2016\data\Gleek.tbl" ==========
1. ¤‹ §‘›ƒ¡— ¥²Íœ´ šŠ ’°€ #Ÿ®Î™‡ 먱Ć ¦ ¯ ž ú˜­Ž ˆ “…
==========end "c:\wyl2016\data\Gleek.tbl" ==========

==========begin "c:\wyl2016\data\zZ-aA.tbl" ==========
1. zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA
==========end "c:\wyl2016\data\zZ-aA.tbl" ==========

The characters for 'Gleek.tbl' will probably not be displayed correctly
in this post, so if you want to recreate the table accurately, use this:

a4 8b 9d a7 91 9b 83 a1 97 8f a5 b2 cd 9c b4 14 9a 8a 15 92 b0 80 16
23 9f ae ce 99 87 17 eb a8 b1 c4 86 7f a6 06 af 1c 9e 0f fa 98 ad 8e
a0 88 1f 8d 93 85 0d 0a

--
Phil Robyn
p r o b y n ( a t ) b e r k e l e y ( d o t ) e d u

Mike Sanders

unread,
May 6, 2017, 8:30:20 AM5/6/17
to
pro...@berkeley.edu wrote:

> Nice, Mike!

Thank you kind sir =)

> Here's some more fun and games for your enjoyment. Win7Pro.
>
> [...]

Wow Phil! I'll be pouring over this awhile.

Earnest thanks for sharing the brainfood (no really,
I enjoy reading these sorts of things).

Now then, about quines...

<https://en.wikipedia.org/wiki/Quine_(computing)>

Kerr Mudd-John

unread,
May 8, 2017, 12:57:02 PM5/8/17
to
I rarely top post, but this is to introduce the sheddi to a useful tool.
Bet it's no good on a Mac!


--
Bah, and indeed, Humbug
0 new messages