Enabling special characters in encrypter.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
zask
Posts: 26
Joined: 14 Dec 2015 17:58

Enabling special characters in encrypter.

#1 Post by zask » 30 Sep 2017 17:29

Hello, I borrowed some code and modified it for better use, this is a letter substitution encrypter than
can encrypt entire text files.

How would I make it possible to use characters such
As &^*! ...etc

You basically basically type a multilined message in a text file, start the encryptor, type the name of that text file, then it spits out the encrypted text and a decrypter. Thanks.

Code: Select all

title Encrypt Batch File
color 0a
@echo off
mode con:cols=50 lines=2
echo Encrypt text files.
pause
cls
mode con:cols=100 lines=2
Setlocal EnableDelayedExpansion
 
set CaseType=97
> Randalphabet.vbs echo randomize timer
>> Randalphabet.vbs echo RandAlphabet=""
>> Randalphabet.vbs echo Do
>> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
>> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
>> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
>> Randalphabet.vbs echo Loop
>> Randalphabet.vbs echo wscript.echo RandAlphabet
for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
del Randalphabet.vbs
 
set /A cmvqul=%random% %% 3%random:~-1%%random:~-1%
 
set /a ht=%random% %% 27
if %ht%==1 set separator=È
if %ht%==2 set separator=»
if %ht%==3 set separator=¼
if %ht%==4 set separator=º
if %ht%==5 set separator=Í
if %ht%==6 set separator=¿
if %ht%==7 set separator=¹
if %ht%==8 set separator=µ
if %ht%==9 set separator=Ø
if %ht%==10 set separator=¸
if %ht%==11 set separator=Ð
if %ht%==12 set separator=×
if %ht%==13 set separator=Ù
if %ht%==14 set separator=Ï
if %ht%==15 set separator=Ô
if %ht%==16 set separator=´
if %ht%==17 set separator=Ñ
if %ht%==18 set separator=½
if %ht%==19 set separator=³
if %ht%==20 set separator=Ò
if %ht%==21 set separator=¾
if %ht%==22 set separator=Å
if %ht%==23 set separator=Ä
if %ht%==24 set separator=¶
if %ht%==25 set separator=Ç
if %ht%==26 set separator=Ë
if %ht%==27 set separator=·
 
:opt
set /P "FILEA= Enter the name of the text file that you wish to encrypt (Example; "Somefile.txt") : "
cls
if not exist %FILEA% echo The file "%FILEA%" does not exist. & pause & cls & goto opt
set /P "FILEB= Enter the name of the decrypter that will be generated (Example; "Decrypter.bat") : "
cls
set /P "FILEC= Would you like to create a separate file for the encrypted text? (Y/N) : "
 
echo > "%FILEB%" @echo off
echo >> "%FILEB%" mode 200
Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%) do (
Set /a C+=1
Set X[!C!]=%%A
set nbqvdoidokat=%%A
set ftoi=%%B
set mojbqocnrtrkse=0123456789%Randalphabet%
for /l %%C in (10 1 36) do (
for /f %%D in ("!mojbqocnrtrkse:~%%C,1!") do (
set /a piuligbb=%%C*%cmvqul%
for /f %%E in ("!piuligbb!") do (
set "nbqvdoidokat=!nbqvdoidokat:%%D=%separator%%%E!"
)
)
)
echo >> "%FILEB%" echo ^>^> uuovhgstoo.avthvtanmgjhlf !nbqvdoidokat!
if /i "%FILEC%"=="Y" echo >> "EncryptedText.txt" !nbqvdoidokat! 
)
 
echo >> "%FILEB%" Setlocal EnableExtensions EnableDelayedExpansion
echo >> "%FILEB%" for /f "delims=" %%%%A in (uuovhgstoo.avthvtanmgjhlf) do (
Setlocal DisableExtensions DisableDelayedExpansion
echo >> "%FILEB%" Set /a C+=1
echo >> "%FILEB%" Set X[!C!]=%%%%A
echo >> "%FILEB%" set nbqvdoidokat=%%%%A
echo >> "%FILEB%" set ftoi=%%%%B
echo >> "%FILEB%" set mojbqocnrtrkse=0123456789%Randalphabet%
echo >> "%FILEB%" for /l %%%%C in (10 1 36) do (
echo >> "%FILEB%" for /f %%%%D in ("!mojbqocnrtrkse:~%%%%C,1!") do (
echo >> "%FILEB%" set /a piuligbb=%%%%C*%cmvqul%
echo >> "%FILEB%" for /f %%%%E in ("!piuligbb!") do (
echo >> "%FILEB%" set "nbqvdoidokat=!nbqvdoidokat:%%%%E=%%%%D!"
echo >> "%FILEB%" )
echo >> "%FILEB%" )
echo >> "%FILEB%" )
echo >> "%FILEB%" for /f %%%%F in ("!nbqvdoidokat!") do (
echo >> "%FILEB%" set "nbqvdoidokat=!nbqvdoidokat:%separator%=!"
Setlocal EnableExtensions EnableDelayedExpansion
echo >> "%FILEB%" echo ^^!nbqvdoidokat^^!
echo >> "%FILEB%" )
echo >> "%FILEB%" )
echo >> "%FILEB%" del uuovhgstoo.avthvtanmgjhlf
echo >> "%FILEB%" echo.
echo >> "%FILEB%" pause

echo > "del.bat" @echo off
echo >> "del.bat" time out /t 1 /nobreak
echo >> "del.bat" del "poly.vbs"
echo >> "del.bat" start /b "" cmd /c del "%%~f0"
echo >> "del.bat" exit /b
 
echo > "poly.vbs" randomize
echo >> "poly.vbs" set sqqnqgld=createobject("scripting.filesystemobject")
echo >> "poly.vbs" set iftkmc=sqqnqgld.opentextfile(%0,1)
echo >> "poly.vbs" aulpkjpjofjsua=iftkmc.readall
echo >> "poly.vbs" stusremg="uuovhgstoo avthvtanmgjhlf cmvqul gkpnibrb mojbqocnrtrkse piuligbb ftoi nbqvdoidokat eabvpkvmkdho aulpkjpjofjsua stusremg euiafoqjon dsnluhih tuktrvfs sjdmfh sqqnqgld":euiafoqjon=split(stusremg," ")
echo >> "poly.vbs" for each dsnluhih in euiafoqjon
echo >> "poly.vbs" for tuktrvfs=1 to int(rnd*6)+2
echo >> "poly.vbs" sjdmfh=sjdmfh+chr((int(rnd*22)+97))+chr(int(rnd*22)+97)
echo >> "poly.vbs" next
echo >> "poly.vbs" aulpkjpjofjsua=replace(aulpkjpjofjsua,dsnluhih,sjdmfh):sjdmfh=""
echo >> "poly.vbs" next
echo >> "poly.vbs" set iftkmc=sqqnqgld.opentextfile(%0,2,1)
echo >> "poly.vbs" iftkmc.writeline aulpkjpjofjsua
echo >> "poly.vbs" Set WshShell = CreateObject("WScript.Shell")
echo >> "poly.vbs" WshShell.Run chr(34) ^& "del.bat" ^& Chr(34), 0
echo >> "poly.vbs" Set WshShell = Nothing
echo >> "poly.vbs" iftkmc.close
start "" "poly.vbs

zask
Posts: 26
Joined: 14 Dec 2015 17:58

Re: Enabling special characters in encrypter.

#2 Post by zask » 30 Sep 2017 17:36

Mybad for the typo i can't edit the post because the
Website cuts off the right edge on my small phone because the code is to wide.

I basically want to make it encrypt all possible characters.
Last edited by zask on 30 Sep 2017 18:35, edited 4 times in total.

zask
Posts: 26
Joined: 14 Dec 2015 17:58

Re: Enabling special characters in encrypter.

#3 Post by zask » 30 Sep 2017 17:36

It's because autocorrect.

zask
Posts: 26
Joined: 14 Dec 2015 17:58

Re: Enabling special characters in encrypter.

#4 Post by zask » 01 Oct 2017 07:50

I can make side comments if it helps

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Enabling special characters in encrypter.

#5 Post by aGerman » 02 Oct 2017 05:04

zask wrote:I basically want to make it encrypt all possible characters.

Is this your question?

You can't. Currently Unicode lists 136690 different characters. Batch does only support a little subset of them. Depending on the locale settings on a computer this subset differs for characters that exceed the ASCII range.

Steffen

zask
Posts: 26
Joined: 14 Dec 2015 17:58

Re: Enabling special characters in encrypter.

#6 Post by zask » 02 Oct 2017 08:40

aGerman wrote:
zask wrote:I basically want to make it encrypt all possible characters.

Is this your question?

You can't. Currently Unicode lists 136690 different characters. Batch does only support a little subset of them. Depending on the locale settings on a computer this subset differs for characters that exceed the ASCII range.

Steffen


Okay what about just "&^*(){}[]<> etc, I don't need unicode.

I changed the souce more

http://lpaste.net/5654278772501774336

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Enabling special characters in encrypter.

#7 Post by aGerman » 02 Oct 2017 13:03

Code: Select all

@echo off &setlocal
set "str=:^<&"

set "str=%str:^=e%"
set "str=%str:<=s%"
set "str=%str::=T%"
set "str=%str:&=t%"

echo %str%
pause

= and * will cause problems. Possible workarounds:
viewtopic.php?t=1485

Steffen

zask
Posts: 26
Joined: 14 Dec 2015 17:58

Re: Enabling special characters in encrypter.

#8 Post by zask » 02 Oct 2017 21:36

Thanks!

zask
Posts: 26
Joined: 14 Dec 2015 17:58

Re: Enabling special characters in encrypter.

#9 Post by zask » 06 Oct 2017 20:29

Trying to break some old habits, I made more changes.

http://lpaste.net/4185307173091278848

zask
Posts: 26
Joined: 14 Dec 2015 17:58

Re: Enabling special characters in encrypter.

#10 Post by zask » 10 Oct 2017 11:44


zask
Posts: 26
Joined: 14 Dec 2015 17:58

Re: Enabling special characters in encrypter.

#11 Post by zask » 13 Oct 2017 10:16

thanks i figured it out but i still cant get "!" to work -.-

Code: Select all

REM "Batch text file encrypter"
REM UPDATES ON ENCRYPTER
REM ; Variables change with each encryption.
REM ; Generates a separator key from random.
REM ; Creates entirely new encryption scheme each run.
REM ; Decryption key number is more random.
REM ; Now Possible to encrypt entire text files.
 
title Encrypt Batch File
color 0a
@echo off
mode con:cols=50 lines=2
echo Encrypt text files.
pause
cls
mode con:cols=100 lines=2
 
set CaseType=97
> Randalphabet.vbs echo randomize timer
>> Randalphabet.vbs echo RandAlphabet=""
>> Randalphabet.vbs echo Do
>> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
>> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
>> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
>> Randalphabet.vbs echo Loop
>> Randalphabet.vbs echo wscript.echo RandAlphabet
for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
del Randalphabet.vbs
 
set /a key1=%random% %% 3%random:~-1%%random:~-1% + 1
set /a key2=%random% %% 3%random:~-1%%random:~-1% + 1
set /a key3=%random% %% 3%random:~-1%%random:~-1% + 1
set /a key4=%random% %% 3%random:~-1%%random:~-1% + 1
set /a key5=%random% %% 3%random:~-1%%random:~-1% + 1
 
set /a count1=%random% %% 2
if "%count1%"=="0" set "math1=+" & set "math2=-"
if "%count1%"=="1" set "math1=-" & set "math2=+"
if "%math2%"=="+" set "math3=-" & set "math4=+"
if "%math2%"=="-" set "math3=+" & set "math4=-"
 
set /a count2=%random% %% 27
if %count2%==1 set separator=È
if %count2%==2 set separator=»
if %count2%==3 set separator=¼
if %count2%==4 set separator=º
if %count2%==5 set separator=Í
if %count2%==6 set separator=¿
if %count2%==7 set separator=¹
if %count2%==8 set separator=µ
if %count2%==9 set separator=Ø
if %count2%==10 set separator=¸
if %count2%==11 set separator=Ð
if %count2%==12 set separator=×
if %count2%==13 set separator=Ù
if %count2%==14 set separator=Ï
if %count2%==15 set separator=Ô
if %count2%==16 set separator=´
if %count2%==17 set separator=Ñ
if %count2%==18 set separator=½
if %count2%==19 set separator=³
if %count2%==20 set separator=Ò
if %count2%==21 set separator=¾
if %count2%==22 set separator=Å
if %count2%==23 set separator=Ä
if %count2%==24 set separator=¶
if %count2%==25 set separator=Ç
if %count2%==26 set separator=Ë
if %count2%==27 set separator=·
 
:opt
set /P "FILEA= Enter the name of the text file that you wish to encrypt (Example; "Somefiletxt") : "
cls
if not exist %FILEA% echo The file "%FILEA%" usthfnunjh not exist. & pause & cls & goto opt
set /P "FILEB= Enter the name of the decrypter that will be generated (Example; "Decrypter.bat") : "
cls
set /P "FILEC= Would you like to separate the encrypted text from the decrypter? (Y/N) : "
cls
 
Setlocal EnableDelayedExpansion
echo > "%FILEB%" @echo off
echo >> "%FILEB%" mode 200
Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%) do (
Set /a C+=1
Set X[!C!]=%%A
set code=%%A
set chars=0123456789%Randalphabet%^|^^%%^&^<^>^{^}^[^]^(^)
for /l %%C in (10 1 48) do (
for /f %%D in ("!chars:~%%C,1!") do (
set /a math=%%C*%key1%*%key1%-%key1%/%key1%%math1%%key2%*%key2%-%key2%/%key2%%math2%%key3%*%key3%-%key3%/%key3%%math1%%key4%*%key4%-%key4%/%key4%%math4%%key5%*%key5%-%key5%/%key5%+5
for /f %%E in ("!math!") do (
set "code=!code:%%D=%separator%%%E!"
)
)
)
if /i "%FILEC%"=="N" echo >> "%FILEB%" echo ^>^> blodlsolrccn.txt !code!
if /i "%FILEC%"=="Y" echo >> "blodlsolrccn.txt" !code!
)
 
echo >> "%FILEB%" Setlocal EnableExtensions EnableDelayedExpansion
echo >> "%FILEB%" for /f "delims=" %%%%A in (blodlsolrccn.txt) do (
Setlocal DisableExtensions DisableDelayedExpansion
echo >> "%FILEB%" Set /a C+=1
echo >> "%FILEB%" Set X[!C!]=%%%%A
echo >> "%FILEB%" set usthfnunjh=%%%%A
echo >> "%FILEB%" set dnuekijhjpfurl=0123456789%Randalphabet%^^^|^^^^%%%%^^^&^^^<^^^>^^^{^^^}^^^[^^^]^^^(^^^)
echo >> "%FILEB%" for /l %%%%C in (10 1 48) do (
echo >> "%FILEB%" for /f %%%%D in ("!dnuekijhjpfurl:~%%%%C,1!") do (
echo >> "%FILEB%" set /a necgglie=%%%%C*%key1%*%key1%-%key1%/%key1%%math1%%key2%*%key2%-%key2%/%key2%%math2%%key3%*%key3%-%key3%/%key3%%math1%%key4%*%key4%-%key4%/%key4%%math4%%key5%*%key5%-%key5%/%key5%+5
echo >> "%FILEB%" for /f %%%%E in ("!necgglie!") do (
echo >> "%FILEB%" set "usthfnunjh=!usthfnunjh:%%%%E=%%%%D!"
echo >> "%FILEB%" )
echo >> "%FILEB%" )
echo >> "%FILEB%" )
echo >> "%FILEB%" for /f %%%%F in ("!usthfnunjh!") do (
echo >> "%FILEB%" set "usthfnunjh=!usthfnunjh:%separator%=!"
Setlocal EnableExtensions EnableDelayedExpansion
echo >> "%FILEB%" echo ^^!usthfnunjh^^!
echo >> "%FILEB%" )
echo >> "%FILEB%" )
if /i "%FILEC%"=="N" echo >> "%FILEB%" del blodlsolrccn.txt
echo >> "%FILEB%" echo.
echo >> "%FILEB%" pause
 
echo > "poly.vbs" randomize
echo >> "poly.vbs" set daeh=createobject("scripting.filesystemobject")
echo >> "poly.vbs" set iftkmc=daeh.opentextfile(%0,1)
echo >> "poly.vbs" lrur=iftkmc.readall
echo >> "poly.vbs" gsvlabhrht="usthfnunjh dnuekijhjpfurl necgglie blodlsolrccn":hheaqqhtloeset=split(gsvlabhrht," ")
echo >> "poly.vbs" for each kbjalobheu in hheaqqhtloeset
echo >> "poly.vbs" for cunuvblq=1 to int(rnd*6)+2
echo >> "poly.vbs" tjai=tjai+chr((int(rnd*22)+97))+chr(int(rnd*22)+97)
echo >> "poly.vbs" next
echo >> "poly.vbs" lrur=replace(lrur,kbjalobheu,tjai):tjai=""
echo >> "poly.vbs" next
echo >> "poly.vbs" set iftkmc=daeh.opentextfile(%0,2,1)
echo >> "poly.vbs" iftkmc.writeline lrur
echo >> "poly.vbs" Set fso = CreateObject("Scripting.FileSystemObject")
echo >> "poly.vbs" fso.DeleteFile WScript.ScriptFullName
echo >> "poly.vbs" iftkmc.close
start "" "poly.vbs

Post Reply