Encrypt a string and read the decrypted one from file

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Posts: 103
Last visit: Tue Apr 26, 2016 9:02 am

Encrypt a string and read the decrypted one from file

Post by hackoo »

I found an useful code on the net to encrypt and decrypt strings.
So i wanted to change it a little , in order to let the encryption and decryption in the same batch and not into two separate files here is the link Batch Encryption

And here is my modified code:

Code: Select all

@echo off
    title Encrypt and decrypt string
    color a
    (set CHAR[a]=UDFM45) & (set CHAR[b]=H21DGF) & (set CHAR[c]=FDH56D) & (set CHAR[d]=FGS546) & (set CHAR[e]=JUK4JH)
    (set CHAR[f]=ERG54S) & (set CHAR[g]=T5H4FD) & (set CHAR[h]=RG641G) & (set CHAR[i]=RG4F4D) & (set CHAR[j]=RT56F6)
    (set CHAR[k]=VCBC3B) & (set CHAR[l]=F8G9GF) & (set CHAR[m]=FD4CJS) & (set CHAR[n]=G423FG) & (set CHAR[o]=F45GC2)
    (set CHAR[p]=TH5DF5) & (set CHAR[q]=CV4F6R) & (set CHAR[r]=XF64TS) & (set CHAR[s]=X78DGT) & (set CHAR[t]=TH74SJ)
    (set CHAR[u]=BCX6DF) & (set CHAR[v]=FG65SD) & (set CHAR[w]=4KL45D) & (set CHAR[x]=GFH3F2) & (set CHAR[y]=GH56GF)
    (set CHAR[z]=45T1FG) & (set CHAR[1]=D4G23D) & (set CHAR[2]=GB56FG) & (set CHAR[3]=SF45GF) & (set CHAR[4]=P4FF12)
    (set CHAR[5]=F6DFG1) & (set CHAR[6]=56FG4G) & (set CHAR[7]=USGFDG) & (set CHAR[8]=FKHFDG) & (set CHAR[9]=IFGJH6)
    (set CHAR[0]=87H8G7) & (set CHAR[@]=G25GHF) & (set CHAR[#]=45FGFH) & (set CHAR[$]=75FG45) & (set CHAR[*]=54GDH5)
    (set CHAR[(]=45F465) & (set CHAR[.]=HG56FG) & (set CHAR[,]=DF56H4) & (set CHAR[-]=F5JHFH) & (set CHAR[ ]=SGF4HF)
    (set CHAR[\]=45GH45) & (set CHAR[/]=56H45G)
    echo Enter a string to encrypt:
    set /p Encrypt=
    set Encrypt2=%Encrypt%
    set "EncryptOut="
    set char=%Encrypt2:~0,1%
    set Encrypt2=%Encrypt2:~1%
    set EncryptOut=%EncryptOut%!CHAR[%char%]!
    if not "%Encrypt2%"=="" goto encrypt2
    set /p CryptedPass=<%~dp0encrypted.txt
    echo Input string clear text ===^> %Encrypt%
    echo Output string crypted ===^> %CryptedPass%
    set /p Decrypt=<%~dp0encrypted.txt
    set Decrypt2=%Decrypt%
    set "DecryptOut="
    set char=%Decrypt2:~0,6%
    set Decrypt2=%Decrypt2:~6%
    set DecryptOut=%DecryptOut%!CHAR[%char%]!
    if not "%Decrypt2%"=="" goto decrypt2
    echo Input string: %Decrypt%
    echo Output string: %DecryptOut%
my problem is in the last part of the code ie the display of the string to read the decrypted string from the text file? he shows me nothing ?
Surely I missed something? but I can't find it where exactly ?
thank you in advance

User avatar
SAPIEN Support Forums
Posts: 945
Last visit: Wed Dec 31, 1969 4:00 pm

Encrypt a string and read the decrypted one from file

Post by SAPIEN Support Forums »

This is an automated post. A real person will respond soon.

Thank you for posting, hackoo.

Here are some hints to help you get an accurate and complete answer to your question.

Ask in the best forum: If you asked in the wrong forum, just copy your question to the right forum.

Anticipate follow-up questions!

Did you remember to include the following?
  • 1. Product, version and build
    2. 32 or 64 bit product
    3. Operating system, e.g. Windows 7 64 bit.
    4. Attach a screenshot, if applicable
    5. Attach logs, crash reports, etc., in a ZIP file
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***