Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off & setlocal enableDelayedExpansion
- set /p "text=Text: "
- set /p "key=Shift: "
- call :rot13 "text" key ciphered
- echo Cipher: %ciphered%
- pause & exit
- :rot13
- setlocal
- set "alphaNum="a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" " ""
- set /a "num=%~2" 2>nul & if "!num!" equ "!%~2!" ( set /a "shiftAlphaNum=4 * num" ) else ( set /a "shiftAlphaNum=4 * 13")
- set "str=X!%~1!" & set "backward=!alphaNum:~%shiftAlphaNum%! !alphaNum:~0,%shiftAlphaNum%!"
- for /L %%a in (8,-1,0) do (
- set /a "length|=1<<%%a"
- for %%b in (!length!) do if "!str:~%%b,1!" equ "" set /a "length&=~1<<%%a"
- )
- (for /l %%a in (0,1,%length%) do ( set "c="!%~1:~%%a,1!" " & set "spaced=!spaced!!c!" )) & set "spaced=!spaced:~0,-3!"
- for %%a in (!spaced!) do ( set /a "n=0", "m=0"
- for %%b in (!alphaNum!) do ( set /a "n+=1"
- if %%b equ %%a for %%c in (%backward%) do ( set /a "m+=1"
- if !n! equ !m! set "out=!out!%%~c"
- )))
- (endlocal
- if "%~3" neq "" ( set "%~3=%out%" ) else ( echo %out%)
- )
- goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement