Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: secrect message batch  (Read 7576 times)

0 Members and 1 Guest are viewing this topic.

Boozu

    Topic Starter


    Hopeful

    Thanked: 9
    • Yes
    • Yes
  • Certifications: List
  • Experience: Familiar
  • OS: Windows 10
secrect message batch
« on: July 02, 2009, 04:50:35 PM »
Hi everyone. Just joined.

I have looked all over the internet for a way to encode a file. What I mean is, I want a batch file to read a text file and wright a new text file with a set output such as "A" in original file is changed to "H" in new file. I would really like it if you could make it so one letter can tern into multiple symbols, "D" = "45". I want to encode a message and send it to someone who will have a decoder (I can revers engineer any code you give me to decode the file). Also I don't need the hole alphabet just a few lines.

a=h, d=45 in the folowing examples
It may be hard but if you can make it look like this:
add add add = h4545 h4545 h4545  :o

This will be fine:
add
add
add =
h4545
h4545
h4545  8)

This will most likely be the easyest to do:
a
d
d

a
d
d

a
d
d=

h
45
45

h
45
45

h
45
45  :)

Thanks for your help.
Don't worry about it.  If it's not good at stock, then it's not good.


devcom



    Apprentice

    Thanked: 37
    Re: secrect message batch
    « Reply #1 on: July 02, 2009, 05:48:40 PM »
    i have encoder but it was project to encode passwords based on random generated keys here is how it looks:
    Code: [Select]
    [ 1:43:15,28]    GENERATING KEY...
    [ 1:43:17,49]    DONE...
    [ 1:43:17,49]    KEY: alED2UCO4kSfmTrypQ678g5W0Bh1ZiNx9v3J
    [ 1:43:17,49]    ENTER PASSWORD TO ENCODE
    [ 1:43:17,49]    [PASSWORD]: computerhope
    [ 1:43:21,78]    GENARATED PASSWORD:
    [ 1:43:21,78]    f91JBQkT59Jk


    [ 1:43:21,79]    GETING KEY...
    [ 1:43:21,79]    DONE...
    [ 1:43:21,79]    KEY: alED2UCO4kSfmTrypQ678g5W0Bh1ZiNx9v3J
    [ 1:43:21,81]    ENTER PASSWORD TO DECODE
    [ 1:43:21,81]    [PASSWORD]: f91jbqkt59jk
    [ 1:43:36,38]    DECODED PASSWORD:
    [ 1:43:36,38]    computerhope

    its not perfect but it works

    i will try to make what you want but one question:

    you want just 'a' and 'd' , or whole alphabet? it would be easier to do sth like this:
    Code: [Select]
    input:
    a=10
    d=45
    o=11
    n=44

    addon
    output:
    1045451144
    Download: Choice.exe

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: secrect message batch
      « Reply #2 on: July 02, 2009, 06:34:52 PM »
      you would want to use better encryption such as AES, etc for this kind of thing. NOT using a batch file and simple caesar cipher like this. Choose a programming language that have encryption modules, etc Python/Perl.

      Boozu

        Topic Starter


        Hopeful

        Thanked: 9
        • Yes
        • Yes
      • Certifications: List
      • Experience: Familiar
      • OS: Windows 10
      Re: secrect message batch
      « Reply #3 on: July 02, 2009, 06:39:48 PM »
      Wow that was fast devcom. i just used "a" and "d" as random examples. If you could you could do 5 or 6 letters of the alphabet I can fill in the rest of it.

      Thanks
      « Last Edit: July 02, 2009, 08:06:41 PM by Boozu »
      Don't worry about it.  If it's not good at stock, then it's not good.


      devcom



        Apprentice

        Thanked: 37
        Re: secrect message batch
        « Reply #4 on: July 03, 2009, 05:05:12 AM »
        you would want to use better encryption such as AES, etc for this kind of thing. NOT using a batch file and simple caesar cipher like this. Choose a programming language that have encryption modules, etc Python/Perl.
        yea i think so too, but batch is fun  ;)
        Download: Choice.exe

        devcom



          Apprentice

          Thanked: 37
          Re: secrect message batch
          « Reply #5 on: July 03, 2009, 10:35:05 AM »
          @Boozu

          Code: [Select]
          @echo off
          setlocal enabledelayedexpansion
          set /p encode=WORD:

          set num=0

          :LOOPE
          call set tmpa=%%encode:~%num%,1%%%
          set /a num+=1
          for /f "tokens=1,2 delims==" %%a in (a.txt) do (
          if "%tmpa%" equ "%%a" set enword=%enword%%%b
          )
          if not "%tmpa%" equ "" goto LOOPE

          echo ENCODE: %enword%
          set num=0

          :LOOPD
          call set tmpa=%%enword:~%num%,2%%%
          set /a num+=1
          for /f "tokens=1,2 delims==" %%a in (a.txt) do (
          if "%tmpa%" equ "%%b" set deword=%deword%%%a
          )
          if not "%tmpa%" equ "" goto LOOPD

          echo DECODE: %deword%
          pause

          a.txt
          Code: [Select]
          a=41
          b=29
          c=16
          d=39

          output:
          Code: [Select]
          WORD: aaadddcb
          ENCODE: 4141413939391629
          DECODE: aaadddcb
          Download: Choice.exe

          Boozu

            Topic Starter


            Hopeful

            Thanked: 9
            • Yes
            • Yes
          • Certifications: List
          • Experience: Familiar
          • OS: Windows 10
          Re: secrect message batch
          « Reply #6 on: July 03, 2009, 12:11:45 PM »
          Wow that's amazing. I found a problem though, if you only use numbers it gets mixed up be and will add random letters.

          a.txt file
          Code: [Select]
          e=35
          l=12
          w=23

          If you have a word with "le" it encodes as 1235, and it decodes as "lwe". That means you can only do so many numbers in the code. That's easy enough to fix with letters. Can you find a way to include spaces and symbols into this. It will show up in the encoded mesage but it will not decode with them. If you want to make this for yourself put a blank line at the top of the a.txt file. And If you want to use capital letters you need to add them in with there own key. Can you make the encode go to a file so i can send it and then plug that code into the decoder?
          Don't worry about it.  If it's not good at stock, then it's not good.


          devcom



            Apprentice

            Thanked: 37
            Re: secrect message batch
            « Reply #7 on: July 03, 2009, 02:20:57 PM »
            sry it was typo in LOOPD so change
            Code: [Select]
            set /a num+=1to
            Code: [Select]
            set /a num+=2in LOOPD
            Download: Choice.exe

            Boozu

              Topic Starter


              Hopeful

              Thanked: 9
              • Yes
              • Yes
            • Certifications: List
            • Experience: Familiar
            • OS: Windows 10
            Re: secrect message batch
            « Reply #8 on: July 03, 2009, 09:55:50 PM »
            Yay. That worked. So if i change the number to, say =5, the a.txt file would have to have a=12345 for the codes (or ,=,,,,, for a comma)? It works with symbols but the folowing will not work, block folowing text, or crash the program ( |^&()!<>~ ) but they are not that impotent. The hard thing is making shour that all of the code is different. But I still want it to send the code to a text file. I can't figure out the code you made so that takes encoded text and puts it in a text file and I can't make it do decoding only. Your program encodes and then decodes it. I know I said I could revers engineer the code you sent me but you sent me a curve ball cuz I wasn't expecting that.

            Thanks for the help.

            a.txt so far. Make shour that you skip the first line.
            Code: [Select]

            a=87
            b=63
            c=60
            d=52
            e=76
            f=39
            g=49
            h=38
            i=31
            j=93
            k=09
            l=82
            m=72
            n=69
            o=13
            p=74
            q=85
            r=10
            s=41
            t=26
            u=61
            v=07
            w=56
            x=32
            y=12
            z=19
             =05
            .=30
            ?=90
            ,=80
            @=36
            #=03
            $=40
            %=08
            _=70
            +=01
            *=06
            -=20
            /=//
            '=''
            :=::
            "=""
            [=[[
            ]=]]
            \=\\
            }=}}
            {={{
            1=55
            2=11
            3=88
            4=77
            5=00
            6=99
            7=22
            8=77
            9=66
            0=44
            Don't worry about it.  If it's not good at stock, then it's not good.


            Boozu

              Topic Starter


              Hopeful

              Thanked: 9
              • Yes
              • Yes
            • Certifications: List
            • Experience: Familiar
            • OS: Windows 10
            Re: secrect message batch
            « Reply #9 on: July 04, 2009, 12:02:58 AM »
            Ok. I made it out put to a file.
            Put this,
            Code: [Select]
            echo %enword%> name of file herehere.
            Code: [Select]
            :LOOPE
            call set tmpa=%%encode:~%num%,1%%%
            set /a num+=1
            for /f "tokens=1,2 delims==" %%a in (a.txt) do (
            if "%tmpa%" equ "%%a" set enword=%enword%%%b
            )
            >>>>>>>>>>HERE<<<<<<<<<<
            if not "%tmpa%" equ "" goto LOOPE
            Don't worry about it.  If it's not good at stock, then it's not good.


            Boozu

              Topic Starter


              Hopeful

              Thanked: 9
              • Yes
              • Yes
            • Certifications: List
            • Experience: Familiar
            • OS: Windows 10
            Re: secrect message batch
            « Reply #10 on: July 04, 2009, 02:30:24 PM »
            Ok. I finally figured out how to decode an input. It was a matter of finding the right :|| variables to switch. I have the code echo to a file called code.txt.
            Code: [Select]
            @echo off
            setlocal enabledelayedexpansion
            set /p decode=CODE:

            set num=0

            :LOOPE
            call set tmpa=%%decode:~%num%,2%%%
            set /a num+=2
            for /f "tokens=1,2 delims==" %%a in (b.txt) do (
            if "%tmpa%" equ "%%a" set deword=%deword%%%b
            )
            echo %deword%> code.txt
            if not "%tmpa%" equ "" goto LOOPE

            echo DECODE: %deword%
            set num=0

            :LOOPD
            call set tmpa=%%deword:~%num%,1%%%
            set /a num+=1
            for /f "tokens=1,2 delims==" %%a in (b.txt) do (
            if "%tmpa%" equ "%%b" set enword=%enword%%%a
            )
            if not "%tmpa%" equ "" goto LOOPD

            echo ENCODE: %enword%
            pause
            To use this you will need to make a file called b.txt with everything flipped around from a.txt.
            Code: [Select]

            87=a
            63=b
            60=c
            52=d
            76=e
            39=f
            49=g
            Again, you need to skip the first line in the file or the "a" will not be read.

            If anyone can make it so that you can use the original a.txt key file for the decoding please post. And thanks devcom for the help.
            Don't worry about it.  If it's not good at stock, then it's not good.


            Helpmeh



              Guru

            • Roar.
            • Thanked: 123
              • Yes
              • Yes
            • Computer: Specs
            • Experience: Familiar
            • OS: Windows 8
            Re: secrect message batch
            « Reply #11 on: July 04, 2009, 02:59:21 PM »
            You could use a similar for loop...

            setlocal enabledelayedexpansion
            for /f "tokens=1,2 delims==" %%a in ('type a.txt') do set decode=!decode:%%b=%%a!
            echo %decode%

            You could put that for loop after this piece of code...so you don't have to type in messages.

            set /p decode=<message.txt

            On the encoder, you can echo the output variable to message.txt then send it to whoever.

            Note that message.txt can only be one line or it will only decode the first line.
            Where's MagicSpeed?
            Quote from: 'matt'
            He's playing a game called IRL. Great graphics, *censored* gameplay.

            devcom



              Apprentice

              Thanked: 37
              Re: secrect message batch
              « Reply #12 on: July 04, 2009, 03:29:44 PM »
              To use this you will need to make a file called b.txt with everything flipped around from a.txt.
              If anyone can make it so that you can use the original a.txt key file for the decoding please post. And thanks devcom for the help.

              my orginal code use only one file

              here:
              Code: [Select]
              :LOOPD
              call set tmpa=%%enword:~%num%,2%%%
              set /a num+=1
              for /f "tokens=1,2 delims==" %%a in (a.txt) do (
              if "%tmpa%" equ "%%b" set deword=%deword%%%a
              )
              if not "%tmpa%" equ "" goto LOOPD


              Quote
              So if i change the number to, say =5, the a.txt file would have to have a=12345 for the codes (or ,=,,,,, for a comma)?
              yes
              Quote
              It works with symbols but the folowing will not work, block folowing text, or crash the program ( |^&()!<>~ ) but they are not that impotent.
              those symbols needs to be escaped:
              Code: [Select]
              H:\Users\_CORE7>echo b & echo a
              b
              a

              H:\Users\_CORE7>echo b ^& echo a
              b & echo a


              EDIT:

              lol Helpmeh you are 1337 (read. leet)  ;D
              Download: Choice.exe

              Boozu

                Topic Starter


                Hopeful

                Thanked: 9
                • Yes
                • Yes
              • Certifications: List
              • Experience: Familiar
              • OS: Windows 10
              Re: secrect message batch
              « Reply #13 on: July 04, 2009, 03:44:19 PM »
              Helpmeh I could not get your code to work. devcom I know that it decodes it but i haven't been able to get it to work with the coded input and decode it. But what I did works and I will work on it to make it code input and decode input and to work with one key file.
              Don't worry about it.  If it's not good at stock, then it's not good.


              devcom



                Apprentice

                Thanked: 37
                Re: secrect message batch
                « Reply #14 on: July 04, 2009, 03:54:18 PM »
                just add another set /p and change var on call set
                Code: [Select]
                set num=0
                set /p word=CODE:
                :LOOPD

                call set tmpa=%%word:~%num%,2%%%
                for /f "tokens=1,2 delims==" %%a in (a.txt) do (
                if "%tmpa%" equ "%%b" set deword=%deword%%%a
                )
                set /a num+=2
                if not "%tmpa%" equ "" goto LOOPD
                echo %deword%
                Download: Choice.exe