title: BATCH: TEXT Encryption/Decryption Batch File
body: <p><strong>Hello</strong> <strong>Everyone</strong>,
  <em>In the first place, thank you for taking some time to read this topic as it's my first post in this forum, and I'm also apologizing for my bad English (I'm Moroccan).</em></p>
  
  <p>So due to a need in my job I had the obligation to do a TEXT encryption program with batch and I'm not so good at it. I'm supposed to do a small Batch program that asks for a password and encrypts the given text, then create a another batch file for decryption. So basically when you encrypt your text you need to give the other person the password and the decryption batch file. Until that nothing to worry about. But the program needs a new "encryption code" every time like "XXXXX belongs to the letter a".</p>
  
  <p>Now I have two problems. The first one is that I'm having an issue while the program is creating the other batch "the decryption one" file i heard that's the"(" or ")" are the cause of the problem.</p>
  
  <p>My second problem is a little bit harder. I need to know how to compile the second batch file or simply hide its code.</p>
  
  <p>Thank you for reading, here's my code. I hope that you'll find a solution for me.</p>
  
  <p>P.S.: I have two syntax error somewhere I can't find them if someone can find them and correct them for me it'll be really nice. And also why is the last line creating the file DECRYPTED_TEXT? Normally it should just write this line in the Decrypter.Bat File.</p>
  
  <pre><code>@echo off
  @echo off
  title TEXT ENCRYPTER BY YOUHACK
  setlocal  ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
  color 0A
  cls
  set string=Loading...
  for /L %%a in (1, 1, 11) do (
  set sting=!string:~0,%%a! 
  echo ^&gt;!sting!
  ping localhost -n 1 &gt;nul
  if %%a GEQ 11 goto eof
  cls 
  )
  :eof
  PING localhost -n 1 &gt;NUL
  echo ________________________________________________________________________________________________________________________
  echo                                              TEXT ENCRYPTER
  echo                                                            V 1.0.0
  echo                                                                   BY YOUHACK
  echo ________________________________________________________________________________________________________________________
  Pause
  if not exist "Output" mkdir Output
  cls
     :HInput
     ::Version 3.0     
     SetLocal DisableDelayedExpansion
  Echo Enter Your Password :
     Set "Line="
     Rem Save 0x08 character in BS variable
     For /F %%# In (
     '"Prompt;$H&amp;For %%# in (1) Do Rem"'
     ) Do Set "BS=%%#"
  
     :HILoop
     Set "Key="
     For /F "delims=" %%# In (
     'Xcopy /L /W "%~f0" "%~f0" 2^&gt;Nul'
     ) Do If Not Defined Key Set "Key=%%#"
     Set "Key=%Key:~-1%"
     SetLocal EnableDelayedExpansion
     If Not Defined Key Goto :HIEnd
     If %BS%==^%Key% (Set /P "=%BS% %BS%" &lt;Nul
     Set "Key="
     If Defined Line Set "Line=!Line:~0,-1!"
     ) Else Set /P "=*" &lt;Nul
     If Not Defined Line (EndLocal &amp;Set "Line=%Key%"
     ) Else For /F delims^=^ eol^= %%# In (
     "!Line!") Do EndLocal &amp;Set "Line=%%#%Key%"
     Goto :HILoop
     :HIEnd
     Echo(
  Echo Your Password Is : "%Line%".&gt;Output/ENCRYPTION_PASSWORD.txt
  set a=%random%
  set b=%random%
  set c=%random%
  set d=%random%
  set e=%random%
  set f=%random%
  set g=%random%
  set h=%random%
  set i=%random%
  set j=%random%
  set k=%random%
  set l=%random%
  set m=%random%
  set n=%random%
  set o=%random%
  set p=%random%
  set q=%random%
  set r=%random%
  set s=%random%
  set t=%random%
  set u=%random%
  set v=%random%
  set w=%random%
  set x=%random%
  set y=%random%
  set z=%random%
  set 0=%random%
  set 1=%random%
  set 2=%random%
  set 3=%random%
  set 4=%random%
  set 5=%random%
  set 6=%random%
  set 7=%random%
  set 8=%random%
  set 9=%random%
  set @=%random%
  set #=%random%
  set $=%random%
  set *=%random%
  set (=%random%
  set )=%random%
  set .=%random%
  set ,=%random%
  set -=%random%
  set  =%random%
  set /=%random%
  set \=%random%
  set é=%random%
  set è=%random%
  set à=%random%
  (set CHAR[a]=%a%) &amp; (set CHAR[b]=%b%) &amp; (set CHAR[c]=%c%) &amp; (set CHAR[d]=%d%) &amp; (set CHAR[e]=%e%)
  (set CHAR[f]=%f%) &amp; (set CHAR[g]=%g%) &amp; (set CHAR[h]=%h%) &amp; (set CHAR[i]=%i%) &amp; (set CHAR[j]=%j%)
  (set CHAR[k]=%k%) &amp; (set CHAR[l]=%l%) &amp; (set CHAR[m]=%m%) &amp; (set CHAR[n]=%n%) &amp; (set CHAR[o]=%o%)
  (set CHAR[p]=%p%) &amp; (set CHAR[q]=%q%) &amp; (set CHAR[r]=%r%) &amp; (set CHAR[s]=%s%) &amp; (set CHAR[t]=%t%)
  (set CHAR[u]=%u%) &amp; (set CHAR[v]=%v%) &amp; (set CHAR[w]=%w%) &amp; (set CHAR[x]=%x%) &amp; (set CHAR[y]=%y%)
  (set CHAR[z]=%z%) &amp; (set CHAR[1]=%1%) &amp; (set CHAR[2]=%2%) &amp; (set CHAR[3]=%3%) &amp; (set CHAR[4]=%4%)
  (set CHAR[5]=%5%) &amp; (set CHAR[6]=%6%) &amp; (set CHAR[7]=%7%) &amp; (set CHAR[8]=%8%) &amp; (set CHAR[9]=%9%)
  (set CHAR[0]=%0%) &amp; (set CHAR[@]=%@%) &amp; (set CHAR[#]=%#%) &amp; (set CHAR[$]=%$%) &amp; (set CHAR[*]=%*%)
  (set CHAR[(]=%(%) &amp; (set CHAR[.]=%.%) &amp; (set CHAR[,]=%,%) &amp; (set CHAR[-]=%-%) &amp; (set CHAR[ ]=% %)
  (set CHAR[\]=%\%) &amp; (set CHAR[/]=%/%) &amp; (set CHAR[é]=%é%) &amp; (set CHAR[è]=%è%) &amp; (set CHAR[à]=%à%)
  cls
  echo Enter The Text To Encrypt:
  set /p Encrypt=
  echo %Encrypt%&gt;Output/UNENCRYPTED_TEXT.txt
  cls
  set Encrypt2=%Encrypt%
  set "EncryptOut="
  :encrypt2
  set char=%Encrypt2:~0,1%
  set Encrypt2=%Encrypt2:~1%
  set EncryptOut=%EncryptOut%!CHAR[%char%]!
  if not "%Encrypt2%"=="" goto encrypt2
  echo Input string: %Encrypt%
  echo.
  echo Output string: %EncryptOut%
  set string=%EncryptOut%
  set temp_str=%string%
  set str_len=0
  :lengthloop
  if defined temp_str (
  set temp_str=%temp_str:~1%
  set /A str_len += 1
  goto lengthloop )
  echo.
  echo Output string is %str_len% characters long.
  echo %EncryptOut%&gt;Output/ENCRYPTED_TEXT.txt
  echo.
  pause
  &gt;Output/DECRYPTER.bat (
    Echo @echo off
    ECHO setlocal  ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
    ECHO title TEXT DECRYPTER BY YOUHACK
    ECHO color 0A
    ECHO :MainMenu
    ECHO echo ________________________________________________________________________________________________________________________
    ECHO echo                                              TEXT DECRYPTER
    ECHO echo                                                            V 1.0.0
    ECHO echo                                                                   BY YOUHACK
    ECHO echo ________________________________________________________________________________________________________________________
    ECHO SET TRUEPASSWORD=%Line%
    ECHO echo Write Your Password Below:
    ECHO set /P Password=
    ECHO IF %%TRUEPASSWORD%%==%%Password%% goto Acess
    ECHO echo Incorrect Password.
    ECHO Pause
    ECHO CLS
    ECHO goto MainMenu
    ECHO :Acess
    ECHO (set CHAR[%a%]=a)
    ECHO (set CHAR[%b%]=b)
    ECHO (set CHAR[%c%]=c)
    ECHO (set CHAR[%d%]=d)
    ECHO (set CHAR[%e%]=e)
    ECHO (set CHAR[%f%]=f)
    ECHO (set CHAR[%g%]=g)
    ECHO (set CHAR[%h%]=h)
    ECHO (set CHAR[%i%]=i)
    ECHO (set CHAR[%j%]=j)
    ECHO (set CHAR[%k%]=k)
    ECHO (set CHAR[%l%]=l)
    ECHO (set CHAR[%m%]=m)
    ECHO (set CHAR[%n%]=n)
    ECHO (set CHAR[%o%]=o)
    ECHO (set CHAR[%p%]=p)
    ECHO (set CHAR[%q%]=q)
    ECHO (set CHAR[%r%]=r)
    ECHO (set CHAR[%s%]=s)
    ECHO (set CHAR[%t%]=t)
    ECHO (set CHAR[%u%]=u)
    ECHO (set CHAR[%v%]=v)
    ECHO (set CHAR[%w%]=w)
    ECHO (set CHAR[%x%]=x)
    ECHO (set CHAR[%y%]=y)
    ECHO (set CHAR[%z%]=z)
    ECHO (set CHAR[%1%]=1)
    ECHO (set CHAR[%2%]=2)
    ECHO (set CHAR[%3%]=3)
    ECHO (set CHAR[%4%]=4)
    ECHO (set CHAR[%5%]=5)
    ECHO (set CHAR[%6%]=6)
    ECHO (set CHAR[%7%]=7)
    ECHO (set CHAR[%8%]=8)
    ECHO (set CHAR[%9%]=9)
    ECHO (set CHAR[%0%]=0)
    ECHO (set CHAR[%@%]=@)
    ECHO (set CHAR[%#%]=#)
    ECHO (set CHAR[%$%]=$)
    ECHO (set CHAR[%*%]=*)
    ECHO (set CHAR[%(%]=()
    ECHO (set CHAR[%.%]=.)
    ECHO (set CHAR[%,%]=,)
    ECHO (set CHAR[%-%]=-)
    ECHO (set CHAR[% %]= )
    ECHO (set CHAR[%\%]=\)
    ECHO (set CHAR[%/%]=/)
    ECHO (set CHAR[%é%]=é)
    ECHO (set CHAR[%è%]=è)
    ECHO (set CHAR[%à%]=à)
    ECHO echo Correct Password .
    ECHO PAUSE
    ECHO echo Enter The Encrypted String To Decrypt:
    ECHO set /p Decrypt=
    ECHO cls
    ECHO set Decrypt2=%Decrypt%
    ECHO set "DecryptOut="
    ECHO :decrypt2
    ECHO set char=%Decrypt2:~0,6%
    ECHO set Decrypt2=%Decrypt2:~6%
    ECHO set DecryptOut=%DecryptOut%!CHAR[%char%]!
    ECHO if not "%Decrypt2%"=="" goto decrypt2
    ECHO echo Encrypted string: %Decrypt%
    ECHO echo.
    ECHO echo Decrypted Text: %DecryptOut%
    ECHO set string=%DecryptOut%
    ECHO set temp_str=%string%
    ECHO set str_len=0
    ECHO :lengthloop
    ECHO if defined temp_str (
    ECHO set temp_str=%temp_str:~1%
    ECHO set /A str_len += 1
    ECHO goto lengthloop )
    ECHO echo.
    ECHO echo The Decrypted Text is %str_len% characters long!
    ECHO echo.%DecryptOut%&gt;&gt;DECRYPTED_TEXT.txt
    ECHO echo.
    ECHO pause
    ECHO cls
  )
  </code></pre>