immernoch keine antwort. vielleicht hilft das folgende batchscript um die vorgestellten algorithmen zu testen.
legt einen benutzernamen an. gebt mindestens ein passwort (minimum 8 stellen) ein. mit exit beendet ihr den ersten passphrase.
gebt dann mindestens ein weiteres passwort (minimum 8 stellen) ein. mit exit beendet ihr den zweiten passphrase.
nun einloggen, dabei aber zuerst den zweiten passphrase eingeben und mit exit beenden nun den zweiten passphrase.
nach dem erfolgreichen login könnt ihr textdateien aus dem ordner text in textdateien in den ordner crpt verschlüsseln.
dazu müssen sowohl quelldatei und zieldatei schon existieren. die zieldatei kann dabei leer sein. umgekehrt ist es möglich
textdateien aus dem ordner crpt in textdateien in den ordner text zu verschlüsseln.
in euren textdateien könnt ihr nur die in eurem schlüssel enthaltenen zeichen verwenden, bei programmstart die folgenden:
wenn ihr einen kürzeren schlüssel erzeugt dann besteht er immer aus den n ersten zeichen dieser zeichenfolge.
so ich hoffe das hilft beim testen der problematik.
auf antworten wird sehnsüchtig gewartet... aber als proof of concept sollte das wohl reichen =)
Code: Alles auswählen
@echo off
mode 89,19
mode con cp select=850> nul
set title=LOKI v.0.1.alfa
title %title%
color 0a
goto start
::FUNCTIONS:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::convert decimal number (0-3999) into roman number:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:gtrmn
if %1 equ 0 set output=__&& goto:eof
if %1 gtr 3999 set output=ERROR1:gtrmn&& goto :eof
if %1 lss 0 set output=ERROR2:gtrmn&& goto :eof
set cnt0=-1
set cnt1=
set prm1=%1
set output=_
:gtrmn0
set /a cnt1=%cnt0%*-1-1
if %cnt0% equ -1 set rmnc1=i&& set rmnc2=v&& set rmnc3=x
if %cnt0% equ -2 set rmnc1=x&& set rmnc2=l&& set rmnc3=c
if %cnt0% equ -3 set rmnc1=c&& set rmnc2=d&& set rmnc3=m
if %cnt0% equ -4 set rmnc1=m&& set rmnc2=q&& set rmnc3=t
if "!prm1:~%cnt1%,1!"=="" goto :eof
if "!prm1:~%cnt0%,1!"=="0" set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="1" set output=%rmnc1%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="2" set output=%rmnc1%%rmnc1%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="3" set output=%rmnc1%%rmnc1%%rmnc1%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="4" set output=%rmnc1%%rmnc2%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="5" set output=%rmnc2%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="6" set output=%rmnc2%%rmnc1%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="7" set output=%rmnc2%%rmnc1%%rmnc1%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="8" set output=%rmnc2%%rmnc1%%rmnc1%%rmnc1%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
if "!prm1:~%cnt0%,1!"=="9" set output=%rmnc1%%rmnc3%%output%&& set /a cnt0=%cnt0%-1&& goto :gtrmn0
set output =ERROR0:gtrmn&& goto :eof
::convert roman number (_-mmmcmxcix) into decimal number::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:gtdcm
set prm1=%1
if not "%prm1:~-1%"=="_" set output=ERROR1:gtdcm&& goto :eof
if "%prm1%"=="__" set output=0&& goto :eof
set cnt0=0
set prm1=!prm1:~0,-1!
set output=
:gtdcm0
if %cnt0% equ 0 set rmnc1=i&& set rmnc2=v&& set rmnc3=x
if %cnt0% equ 1 set rmnc1=x&& set rmnc2=l&& set rmnc3=c
if %cnt0% equ 2 set rmnc1=c&& set rmnc2=d&& set rmnc3=m
if %cnt0% equ 3 set rmnc1=m&& set rmnc2=q&& set rmnc3=t
if "%prm1%"=="" set prm1=%1&& goto :eof
if "%prm1:~-4%"=="%rmnc2%%rmnc1%%rmnc1%%rmnc1%" set output=8%output%&& set prm1=%prm1:~0,-4%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if "%prm1:~-3%"=="%rmnc2%%rmnc1%%rmnc1%" set output=7%output%&& set prm1=%prm1:~0,-3%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if "%prm1:~-3%"=="%rmnc1%%rmnc1%%rmnc1%" set output=3%output%&& set prm1=%prm1:~0,-3%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if "%prm1:~-2%"=="%rmnc1%%rmnc3%" set output=9%output%&& set prm1=%prm1:~0,-2%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if "%prm1:~-2%"=="%rmnc2%%rmnc1%" set output=6%output%&& set prm1=%prm1:~0,-2%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if "%prm1:~-2%"=="%rmnc1%%rmnc2%" set output=4%output%&& set prm1=%prm1:~0,-2%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if "%prm1:~-2%"=="%rmnc1%%rmnc1%" set output=2%output%&& set prm1=%prm1:~0,-2%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if "%prm1:~-1%"=="%rmnc2%" set output=5%output%&& set prm1=%prm1:~0,-1%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if "%prm1:~-1%"=="%rmnc1%" set output=1%output%&& set prm1=%prm1:~0,-1%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
if not %cnt0% geq 3 set output=0%output%&& set /a cnt0=%cnt0%+1&& goto :gtdcm0
set output=ERROR0:gtdcm&& goto :eof
::check keystring (length, parts, double characters, known characters, known roman digits)::::::::::::::::::::::::::::::::::::::::::::::::::
:chkks
if "%rootkey%"=="" set output=ERROR1:chkks&& goto :eof
set prm1=%rootkey%
set cnt0=0
set output=
:chkks0
title %title% check length %cnt0% done
if not "!prm1:~%cnt0%,1!"=="" set /a cnt0=%cnt0%+1&& goto :chkks0
if not %cnt0% geq 54 set output=ERROR2:chkks&& goto :eof
title %title% check mod 2
set /a cnt1=%cnt0%%%2
if not %cnt1% equ 0 set output=ERROR3:chkks&& goto :eof
set /a cnt0=%cnt0%/2
set prm1h1=!prm1:~0,%cnt0%!
set prm1h2=!prm1:~-%cnt0%!
set cnt0=0
set cnt1=1
:chkks1
title %title% check double characters %cnt0%[!prm1h1:~%cnt0%,1!] %cnt1%[!prm1h1:~%cnt1%,1!]
if "!prm1h1:~%cnt0%,1!"=="!prm1h1:~%cnt1%,1!" set output=ERROR4:chkks %cnt0% %cnt1%&& goto :eof
set /a cnt1=%cnt1%+1
if "!prm1h1:~%cnt1%,1!"=="" set /a cnt1=%cnt0%+2&& set /a cnt0=%cnt0%+1
if "!prm1h1:~%cnt1%,1!"=="" goto :chkks2
goto chkks1
:chkks2
set cnt0=0
attrib -h -s -r check.log
:chkks2a
title %title% check known characters %cnt0% done
if "!prm1h1:~%cnt0%,1!"=="" goto :chkks2b
find /c "!prm1h1:~%cnt0%,1!" data/charset.log> check.log
for /f "tokens=2 delims=:" %%a in (check.log) do set cnt1=%%a
if %cnt1:~1,1% equ 0 set output=ERROR5:chkks !prm1h1:~%cnt0%,1!&& goto :eof
set /a cnt0=%cnt0%+1&& goto :chkks2a
:chkks2b
attrib +h +s +r check.log
set cnt0=0
set chk_=0
set chki=0
set chkv=0
set chkx=0
set chkl=0
set chkc=0
:chkks3
title %title% check known roman digits %cnt0% done
if not "!prm1h2:~%cnt0%,1!"=="_" if not "!prm1h2:~%cnt0%,1!"=="i" if not "!prm1h2:~%cnt0%,1!"=="v" if not "!prm1h2:~%cnt0%,1!"=="x" if not "!prm1h2:~%cnt0%,1!"=="l" if not "!prm1h2:~%cnt0%,1!"=="c" set output=ERROR6:chkks !prm1h2:~%cnt0%,1! %cnt0%&& goto :eof
if "!prm1h2:~%cnt0%,1!"=="_" set /a chk_=%chk_%+1
if "!prm1h2:~%cnt0%,1!"=="i" set /a chki=%chki%+1
if "!prm1h2:~%cnt0%,1!"=="v" set /a chkv=%chkv%+1
if "!prm1h2:~%cnt0%,1!"=="x" set /a chkx=%chkx%+1
if "!prm1h2:~%cnt0%,1!"=="l" set /a chkl=%chkl%+1
if "!prm1h2:~%cnt0%,1!"=="c" set /a chkc=%chkc%+1
set /a cnt0=%cnt0%+1
if "!prm1h2:~%cnt0%,1!"=="" goto :chkks4
:: if "!prm1h2:~%cnt0%,1!"=="" goto :chkks5
goto :chkks3
:chkks4
title %title% check count of roman digits
if %chk_% lss 4 set output=ERROR7:chkks _ %chk_%&& goto :eof
if %chki% lss 4 set output=ERROR7:chkks i %chki%&& goto :eof
if %chkv% lss 4 set output=ERROR7:chkks v %chkv%&& goto :eof
if %chkx% lss 4 set output=ERROR7:chkks x %chkx%&& goto :eof
if %cnt0% geq 43 if %chkl% lss 4 set output=ERROR7:chkks l %chkl%&& goto :eof
if %cnt0% geq 93 if %chkc% lss 4 set output=ERROR7:chkks c %chkc%&& goto :eof
title %title%
set output=ERROR0:chkks&& goto :eof
::generate random key:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:gtrdm
if "%gtrdm%"=="" set output=ERROR1:gtrdm&& goto :eof
set prm1=%gtrdm%
set cnt0=0
set cnt1=
set output=
:gtrdm0
title %title% caesars salad prescan %cnt0% done
if not "!prm1:~%cnt0%,1!"=="" set /a cnt0=%cnt0%+1&& goto :gtrdm0
set /a cnt0=%cnt0%/2
set prm1h1=!prm1:~0,%cnt0%!
set prm1h2=!prm1:~%cnt0%!
set cnt1=%cnt0%
set hlp1=
set hlp2=
set hlp3=
:gtrdm1
title %title% caesars salad mixing A %cnt1% left
set /a hlp1=%random%%%cnt1%
set /a hlp2=%hlp1%+1
set /a cnt1=%cnt1%-1
set hlp3=%hlp3%!prm1h1:~%hlp1%,1!&& set prm1h1=!prm1h1:~0,%hlp1%!!prm1h1:~%hlp2%!
if not %cnt1% equ 1 goto :gtrdm1
set output=%hlp3%%prm1h1%
set cnt1=%cnt0%
set hlp1=
set hlp2=
set hlp3=
:gtrdm2
title %title% caesars salad mixing B %cnt1% left
set /a hlp1=%random%%%cnt1%
set /a hlp2=%hlp1%+1
set /a cnt1=%cnt1%-1
set hlp3=%hlp3%!prm1h2:~%hlp1%,1!&& set prm1h2=!prm1h2:~0,%hlp1%!!prm1h2:~%hlp2%!
if not %cnt1% equ 1 goto :gtrdm2
set output=%output%%hlp3%%prm1h2%&& set prm1h1=!prm1:~0,%cnt0%!&& set prm1h2=!prm1:~%cnt0%!&& title %title%&& goto :eof
set output=ERROR0:gtrdm&& goto :eof
::set key values::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:stkvl
if "%rootkey%"=="" set output=ERROR1:stkvl&& goto:eof
set prm1=%rootkey%
set cnt0=0
set output=
set rmncnt_=0
set rmncnti=0
set rmncntv=0
set rmncntx=0
set rmncntl=0
set rmncntc=0
:stkvl0
if not "!prm1:~%cnt0%,1!"=="" set /a cnt0=%cnt0%+1&& goto :stkvl0
set /a cnt1=%cnt0%/2
set prm1h1=!prm1:~0,%cnt1%!
set prm1h2=!prm1:~%cnt1%!
set cnt0=0
for %%a in (rome_ romei romev romex romel) do set %%a=
:stkvl1
title=%title% set key values: !prm1h1:~%cnt0%,1! = %cnt0% ^| !prm1h1:~%cnt0%,1! = !prm1h2:~%cnt0%,1!
if "!prm1h1:~%cnt0%,1!"=="" goto :stkvl2
set val_%cnt0%=!prm1h1:~%cnt0%,1!
set chr_!prm1h1:~%cnt0%,1!=%cnt0%
if "!prm1h2:~%cnt0%,1!"=="_" set rome_=%rome_%!prm1h1:~%cnt0%,1!&& set rom!prm1h1:~%cnt0%,1!=_&& set /a rmncnt_=%rmncnt_%+1
if "!prm1h2:~%cnt0%,1!"=="i" set romei=%romei%!prm1h1:~%cnt0%,1!&& set rom!prm1h1:~%cnt0%,1!=i&& set /a rmncnti=%rmncnti%+1
if "!prm1h2:~%cnt0%,1!"=="v" set romev=%romev%!prm1h1:~%cnt0%,1!&& set rom!prm1h1:~%cnt0%,1!=v&& set /a rmncntv=%rmncntv%+1
if "!prm1h2:~%cnt0%,1!"=="x" set romex=%romex%!prm1h1:~%cnt0%,1!&& set rom!prm1h1:~%cnt0%,1!=x&& set /a rmncntx=%rmncntx%+1
if "!prm1h2:~%cnt0%,1!"=="l" set romel=%romel%!prm1h1:~%cnt0%,1!&& set rom!prm1h1:~%cnt0%,1!=l&& set /a rmncntl=%rmncntl%+1
if "!prm1h2:~%cnt0%,1!"=="c" set romec=%romec%!prm1h1:~%cnt0%,1!&& set rom!prm1h1:~%cnt0%,1!=c&& set /a rmncntc=%rmncntc%+1
set /a cnt0=%cnt0%+1&& goto :stkvl1
:stkvl2
set klngth=%cnt0%
title %title%
set output=ERROR0:vgnrk&& goto :eof
::modified vigenere shift:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:vgnrk
if "%rootkey%"=="" set output=ERROR1:vgnrk&& goto :eof
if "%klngth%"=="" set output=ERROR2:vgnrk&& goto :eof
set prm1=%rootkey%
set prm1h1=!prm1:~0,%klngth%!
set prm1h2=!prm1:~-%klngth%!
set prm2=%1
if "%prm2:~7,1%"=="" set output=ERROR3:vgnrk&& goto :eof
set cnt0=0
set cnt1=0
set cnt2=
set cnt3=
set cnt4=
set output=
set hlp1=
set nks1= %
set nks2= %
set nks1=!nks1:~0,%klngth%!
set nks2=!nks2:~0,%klngth%!
:vgnrk0
title %title% vigenere shift !prm1h1:~%cnt0%,1! ^> !prm2:~%cnt1%,1! ^| !prm2:~%cnt1%,1! ^< !prm1h2:~%cnt0%,1!
if "!prm1h1:~%cnt0%,1!"=="" goto :vgnrk3
if "!prm2:~%cnt1%,1!"=="" set cnt1=0
set hlp1=!prm1h2:~%cnt1%,1!
set cnt2=!chr_%hlp1%!
set /a cnt3=%cnt0%+%cnt2%
:vgnrk1
if %cnt3% geq %klngth% set /a cnt3=%cnt3%-%klngth%
if not "!nks1:~%cnt3%,1!"==" " set /a cnt3=%cnt3%+1&& goto :vgnrk1
set /a cnt4=%cnt3%+1
set nks1=!nks1:~0,%cnt3%!!prm1h1:~%cnt0%,1!!nks1:~%cnt4%!
set /a cnt3=%cnt0%-%cnt2%
:vgnrk2
if %cnt3% lss 0 set /a cnt3=%cnt3%+%klngth%
if not "!nks2:~%cnt3%,1!"==" " set /a cnt3=%cnt3%-1&& goto :vgnrk2
set /a cnt4=%cnt3%+1
set nks2=!nks2:~0,%cnt3%!!prm1h2:~%cnt0%,1!!nks2:~%cnt4%!
set /a cnt0=%cnt0%+1
set /a cnt1=%cnt1%+1
goto :vgnrk0
:vgnrk3
title %title%
set output=%nks1%%nks2%&& goto :eof
set output=ERROR0:vgnrk&& goto :eof
::encryption method 1 advanced caesar:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:ncrpt
if "%ncrpt%"=="" set output=ERROR1:ncrpt&& goto :eof
if "%rootkey%"=="" set output=ERROR2:ncrpt&& goto :eof
if "%klngth%"=="" set output=ERROR3:ncrpt&& goto :eof
set prm1=%ncrpt%
set cnt0=0
set /a hlp1=%random%%%klngth%
set hlp2=
set hlp3=
set output=!val_%hlp1%!
:ncrpt0
title %title% encryption advanced caesar [%cnt0%]
if "!prm1:~%cnt0%,1!"=="" title %title%&& goto :eof
set hlp1=%output:~-1%
set hlp2=!chr_%hlp1%!
set hlp1=!prm1:~%cnt0%,1!
set hlp3=!chr_%hlp1%!
set /a cnt1=%hlp2%+%hlp3%
if %cnt1% geq %klngth% set /a cnt1=%cnt1%-%klngth%
set output=%output%!val_%cnt1%!
set /a cnt0=%cnt0%+1
goto :ncrpt0
set output=ERROR0:ncrpt&& title %title%&& goto :eof
::decryption method 1 advanced caesar:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:dcrpt
if "%dcrpt%"=="" set output=ERROR1:dcrpt&& goto :eof
if "%rootkey%"=="" set output=ERROR2:dcrpt&& goto :eof
if "%klngth%"=="" set output=ERROR3:dcrpt&& goto :eof
set prm1=%dcrpt%
set cnt0=0
set cnt1=
set hlp1=
set hlp2=
set hlp3=
set output=
:dcrpt0
title %title% decryption advanced caesar [%cnt0%]
set /a cnt1=%cnt0%+1
if "!prm1:~%cnt1%,1!"=="" title %title%&& goto :eof
set hlp1=!dcrpt:~%cnt0%,1!
set hlp2=!chr_%hlp1%!
set hlp1=!dcrpt:~%cnt1%,1!
set hlp3=!chr_%hlp1%!
set /a hlp1=%hlp3%-%hlp2%
if %hlp1% lss 0 set /a hlp1=%hlp1%+%klngth%
set output=%output%!val_%hlp1%!
set /a cnt0=%cnt0%+1
goto :dcrpt0
set output=ERROR0:dcrpt&& title %title%&& goto :eof
::encryption method 2 home rome:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:gtrnc
if "%gtrnc%"=="" set output=ERROR1:gtrnc&& goto:eof
if "%klngth%"=="" set output=ERROR2:gtrnc&& goto:eof
set prm1=%gtrnc%
set cnt0=0
set cnt1=
set hlp1=
set hlp2=
set output=
:gtrnc0
title %title% encryption home rome [%cnt0%]
if "!prm1:~%cnt0%,1!"=="" title %title%&& goto :eof
if not "!prm1:~%cnt0%,1!"=="_" if not "!prm1:~%cnt0%,1!"=="i" if not "!prm1:~%cnt0%,1!"=="v" if not "!prm1:~%cnt0%,1!"=="x" if not "!prm1:~%cnt0%,1!"=="l" if not "!prm1:~%cnt0%,1!"=="c" set output=ERROR1:gtrnc&& goto :eof
set hlp1=!prm1:~%cnt0%,1!
set /a cnt1=%random%%%!rmncnt%hlp1%!
set hlp2=!rome%hlp1%!
set output=%output%!hlp2:~%cnt1%,1!
set /a cnt0=%cnt0%+1
goto :gtrnc0
set output=ERROR0:gtrnc&& title %title%&& goto :eof
::decryption method 2 home rome:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:gtrdc
if "%gtrdc%"=="" set output=ERROR1:gtrdc&& goto:eof
if "%klngth%"=="" set output=ERROR2:gtrdc&& goto:eof
set prm1=%gtrdc%
set cnt0=0
set hlp1=
set output=
:gtrdc0
title %title% decryption home rome [%cnt0%]
if "!prm1:~%cnt0%,1!"=="" title %title%&& goto :eof
set hlp1=!prm1:~%cnt0%,1!
set output=%output%!rom%hlp1%!
set /a cnt0=%cnt0%+1
goto :gtrdc0
set output=ERROR0:gtrdc&& goto :eof
::encryption method 2 home rome base::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:gtrms
if "%gtrms%"=="" set output=ERROR1:gtrms&& goto :eof
set mprm1=%gtrms%
set mcnt0=0
set moutput=
set mhlp1=
:gtrms0
title %title% encryption home rome base [%mcnt0%]
if "!mprm1:~%mcnt0%,1!"=="" goto :gtrms1
set mhlp1=!mprm1:~%mcnt0%,1!
set mhlp1=!chr_%mhlp1%!
call :gtrmn %mhlp1%
set moutput=%moutput%%output%
set /a mcnt0=%mcnt0%+1
goto :gtrms0
:gtrms1
title %title%
set output=%moutput%
if "%output%"=="" set output=ERROR0:gtrms&& goto :eof
goto :eof
::decryption method 2 home rome base::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:gtchs
if "%gtchs%"=="" set output=ERROR1:gtchs&& goto :eof
set mprm1=%gtchs%
set mcnt0=0
set mcnt1=1
set moutput=
set mhlp1=
:gtchs0
title %title% decryption home rome base [%mcnt0%]
if "!mprm1:~%mcnt0%,1!"=="" goto :gtchs2
if "!mprm1:~%mcnt0%,1!"=="_" if not "%mhlp1%"=="" set mhlp1=%mhlp1%!mprm1:~%mcnt0%,1!&& goto :gtchs1
set mhlp1=%mhlp1%!mprm1:~%mcnt0%,1!
:: if "!mprm1:~%mcnt0%,1!"=="_" if "!mprm1:~%mcnt1%,1!"=="_" if not "!mprm1:~%mcnt1%,2!"=="__" set mhlp1=__&& set/a mcnt0=%mcnt0%+1&& goto :gtchs1
:: if "!mprm1:~%mcnt0%,1!"=="_" if not "!mprm1:~%mcnt1%,1!"=="_" goto :gtchs1
:: if "!mprm1:~%mcnt0%,1!"=="_" if "!mprm1:~%mcnt1%,2!"=="__" goto :gtchs1
set /a mcnt0=%mcnt0%+1
set /a mcnt1=%mcnt0%+1
goto :gtchs0
:gtchs1
:: echo %mhlp1%
call :gtdcm %mhlp1%
set mhlp1=%output%
set mhlp1=!val_%mhlp1%!
set moutput=%moutput%%mhlp1%
set mhlp1=
set /a mcnt0=%mcnt0%+1
set /a mcnt1=%mcnt0%+1
goto :gtchs0
:gtchs2
title %title%
set output=%moutput%
if "%output%"=="" set output=ERROR0:gtchs&& goto :eof
goto :eof
::set default rootkey:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:gtdft
set rootchr=abcdefghijklmnopqrstuvwxyz_0123456789.?,;'-+:()[]~#\@üäèïîìÄÅÉæÆôöòûùÜø£ƒáóúñªº¿®¬½¼¡«»ÁÂÀ©¢Ã¤ÐÊËÈÍÎÏ̯ßõÕþÚÛÙýÝ´±¾§¸°¨¹³²
set rootrmn=_iv_iv_ivx_ix_ix_ivx_ivx_ivx_ivx_ivx_ixllll_ivxl_ivxl_ixl_ixl_ixl_ixl_ixl_ixl_ix_ivx_ivx_cccc_ivxc_ixc_ivxc_ixc_ivxc_ixc_ix
set rootkey=%rootchr%%rootrmn%
set klngth=123
goto :eof
::set keylength:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:sklngt
if "%1"=="" set output=ERROR1:sklngt&& goto :eof
if %1 lss 27 set output=ERROR2:sklngt&& goto :eof
if %1 gtr 123 set output=ERROR3:sklngt&& goto :eof
set cnt0=%1
call :gtdft
set sklngt=!rootchr:~0,%cnt0%!!rootrmn:~0,%cnt0%!
set output=ERROR0:sklngth&& goto :eof
::create account::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:acccrt
call :gtdft
call :stkvl
call :mltpl
if not "%acccrt%"=="" set gtrdm=%acccrt%
if "%acccrt%"=="" set gtrdm=%rootkey%
call :gtrdm
if not "%acccrt%"=="" set ghlp1=%output%
set ncrpt=%output%
call :ncrpt
set ncrpt=%output%
call :gtdft
call :stkvl
call :mltpl
call :ncrpt
echo %output%> user/%name%.log
call :gtdft
call :stkvl
goto :eof
::multiple passwords::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:mltpl
cls
set /p psswrd=password: %
:: if "%psswrd%"=="exit" goto :eof
if "%psswrd:~7,1%"=="" goto :mltpl
call :vgnrk %psswrd%
set rootkey=%output%
call :stkvl
:mltpl0
cls
set /p psswrd=add more: %
if "%psswrd%"=="exit" goto :eof
if "%psswrd:~7,1%"=="" goto :mltpl0
call :vgnrk %psswrd%
set rootkey=%output%
call :stkvl
goto :mltpl0
::encipher textfile:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:ncphr
if "%ncphr%"=="" set output=ERROR1:ncphr&& goto :eof
if "%1"=="" set output=ERROR2:ncphr&& goto :eof
set ncrpt=%ncphr%
call :ncrpt
set ncrpt=%output%
call :ncrpt
set ncrpt=%output%
call :ncrpt
set gtrms=%output%
call :gtrms
set gtrnc=%output%
call :gtrnc
set ncrpt=%output%
call :ncrpt
set ncrpt=%output%
call :ncrpt
set ncrpt=%output%
call :ncrpt
echo %output%>> crpt/%1.txt
goto :eof
::decipher textfile:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:dcphr
if "%dcphr%"=="" set output=ERROR1:dcphr&& goto :eof
if "%1"=="" set output=ERROR2:dcphr&& goto :eof
set dcrpt=%dcphr%
call :dcrpt
set dcrpt=%output%
call :dcrpt
set dcrpt=%output%
call :dcrpt
set gtrdc=%output%
call :gtrdc
set gtchs=%output%
call :gtchs
set dcrpt=%output%
call :dcrpt
set dcrpt=%output%
call :dcrpt
set dcrpt=%output%
call :dcrpt
echo %output%>> text/%1.txt
goto :eof
::helpfile::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:help
cls
echo LOKI is a batchscript for encrypting and decrypting textfiles.
echo.
echo LOKI uses passphrases instead of a password for the login.
echo each passphrase consists of at least 1 up to n passwords.
echo.
echo when setup an account, LOKI will first ask for passphrase A, afterwards for passphrase B
echo if you want to login you have to enter first passphrase B, afterwards passphrase A
echo.
echo LOKI allows the following characters in a textfile to work with:
echo.
echo abcdefghijklmnopqrstuvwxyz_0123456789.?,;'-+:()[]~
echo #\@üäèïîìÄÅÉæÆôöòûùÜø£ƒáóúñªº¿®¬½¼¡«»ÁÂÀ©¢Ã¤ÐÊËÈÍÎ
echo Ï̯ßõÕþÚÛÙýÝ´±¾§¸°¨¹³²
echo.
echo this means LOKI also understands no "SPACE".
echo if using any other characters than the allowed ones may crash LOKI.
pause> nul&& goto :eof
::LOGIC:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::proof setlocal, operating system, cmd version, needed folders, needed files:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:start
if not exist crpt md crpt
if not exist data md data
if not exist text md text
if not exist user md user
if not exist check.log echo _> check.log&& attrib +h +s +r check.log
setlocal ENABLEEXTENSIONS
cls
if not "%ERRORLEVEL%"=="0" echo extensions not available&&echo programm shutting down&& pause> nul&& goto :eof
setlocal enabledelayedexpansion
cls
if not "%ERRORLEVEL%"=="0" echo delayed expansion not available&&echo programm shutting down&& pause> nul&& goto :eof
if not "%CMDEXTVERSION%"=="2" echo command extensions version not guilty.&& echo program maybe not working&& pause> nul
wmic os get caption, OSArchitecture> data/winvrs.log
attrib -r -s -h data/charset.log
find /i /c "Microsoft Windows 10" data/winvrs.log> data/charset.log
for /f "tokens=3" %%a in (data/charset.log) do set hlp1=%%a
if not "%hlp1%"=="1" echo windows version not guilty.&& echo program maybe not working&& pause> nul
set hlp1=
call :gtdft
echo %rootchr%> data/charset.log&& attrib +r +s +h data/charset.log
call :stkvl
:restart
::login procedure:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
cls
echo "exit" shutdown program
echo "help" help
set /p name=account: %
if "%name%"=="exit" endlocal&& goto :eof
if "%name%"=="help" call :help
if "%name%"=="help" goto :restart
if not exist user/%name%.log (
echo account not found. want to create [%name%]?
choice
if !ERRORLEVEL! equ 1 call :acccrt
goto :restart
)
call :mltpl
set /p dcrpt=< user/%name%.log
call :dcrpt
set dcrpt=%output%
call :gtdft
call :stkvl
call :mltpl
call :dcrpt
set rootkey=%output%
call :chkks
if not "%output%"=="ERROR0:chkks" call :gtdft&& call :stkvl&& goto restart
set title=%title% ---- account: [%name%]%
title %title%
call :stkvl
cls
echo login successful
echo
pause> nul
::choose task:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:restart0
cls
echo encrypt [1], decrypt [2], set new keylength [3], exit [4]
choice /c 1234
if "%ERRORLEVEL%"=="1" (
:rst0e1
cls
set /p uhlp1=source: %
if "!uhlp1!"=="" goto :rst0e1
if not exist text/!uhlp1!.txt goto :rst0e1
:rst0e1a
cls
set /p uhlp2=destination: %
if "!uhlp2!"=="" goto :rst0e1a
if not exist crpt/!uhlp2!.txt goto :rst0e1a
for /f %%a in (text/!uhlp1!.txt) do set ncphr=%%a&& call :ncphr !uhlp2!
cls
echo text^/!uhlp1!.txt encrypted to crpt^/!uhlp2!.txt
echo
pause> nul
goto :restart0
)
if "%ERRORLEVEL%"=="2" (
:rst0e2
cls
set /p uhlp1=source: %
if "!uhlp1!"=="" goto :rst0e2
if not exist crpt/!uhlp1!.txt goto :rst0e2
:rst0e2a
cls
set /p uhlp2=destination: %
if "!uhlp2!"=="" goto :rst0e2a
if not exist text/!uhlp2!.txt goto :rst0e2a
for /f %%a in (crpt/!uhlp1!.txt) do set dcphr=%%a&& call :dcphr !uhlp2!
cls
echo crpt^/!uhlp1! decrypted to text^/!uhlp2!
echo
pause> nul
goto :restart0
)
if "%ERRORLEVEL%"=="3" (
cls
echo set new keylength makes it impossible to decrypt old files
choice
if "!ERRORLEVEL!"=="1" (
:rst0e3
cls
set /p uhlp1=length: %
call :sklngt !uhlp1!
if not "!output!"=="ERROR0:sklngth" goto :rst0e3
set acccrt=!sklngt!
call :acccrt
set rootkey=!ghlp1!
call :stkvl
goto :restart0
)
if "!ERRORLEVEL!"=="2" goto :restart0
)
if "%ERRORLEVEL%"=="4" endlocal&& goto :eof
goto :restart0