Computing.Net > Forums > Programming > Batch file Encoder

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Batch file Encoder

Reply to Message Icon

Name: Matt (by Mattio)
Date: November 1, 2009 at 07:41:07 Pacific
OS: windows XP
CPU/Ram: 1.397 GHz / 958 MB
Product: Toshiba / Satellite m40
Subcategory: Batch
Comment:

Creating an Encoder cause I'm bored.

I have a problem.
I ask for the users input to a variable called %Sentence%
But what I'm struggling to do is to change each letter.
Basically i want the user to enter a sentence, Then when they Press enter, the program will Change each letter to another letter.
For example
User enters : Hello world
Output is : Ifmmp xpsme

That is every letter moved up in the alphabet 1 place.
So the batch will encode it by algorithm.
Thing is. I have no idea how to extract each letter from the variable and change it.
I'll also be decoding it too but once i got this code i should be able to reverse it easy.

Any ideas ?

******************************************
MSN = HardstyleMatt@hotmail.co.uk
Need help? Just ask. :)
******************************************



Sponsored Link
Ads by Google

Response Number 1
Name: gtaion
Date: November 1, 2009 at 19:59:00 Pacific
Reply:

I started thinking and to get this done, I'm thinking you need to break your sentences down by the letter and the convert it and re-assemble. The following is what I've come up with so far. . . I got it to the point that it breaks it down by letter then assigns each letter a number, which you should be able to use on the alphabet to change the letter, but I can't get the variable modifier to work and grab what would be the next letter in the alphabet. So this is what I have so far, but it's broke and I can't figure out why it's not working


@echo off
SetLocal EnableDelayedExpansion
set Alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZA
set Alpha=%Alpha%abcdefghijklmnopqrstuvwxyza

set /p sentance=Enter your sentance:

set /a i = -1
:start
set /a i += 1

For /f "Tokens=*" %%a in ("!sentance:~%i%,1!") do (
if [%%a]==[] echo. & goto Start
set v=%%a
For %%b in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
set /a Count+=1
if "%%b"=="!v!" (
Set /A Letter=!Count!+0
))
Echo %Alpha:~!Letter!,1%
set Count=
set Letter=
goto start
)
set i=


0

Response Number 2
Name: Matt (by Mattio)
Date: November 2, 2009 at 03:24:50 Pacific
Reply:

Thanks for replying.
I have no idea either, I'm not as advanced in this as you lol.
I can see how it works.

Couldn't you have each letter Assigned a number in a var.
Then as the code converts it to a number, it should be able to add 1 then display the letter corresponding to that number.

Like...

@ECHO OFF
SetLocal EnableDelayedExpansion
Set A=1
Set B=2
Set C=3
..etc

Then as your code converts it to a number, it can then add 1, then display the letter.

If this sounds like utter rubbish it's cause im not too good at this lol. Just an idea :-)

******************************************
MSN = HardstyleMatt@hotmail.co.uk
Need help? Just ask. :)
******************************************


0

Response Number 3
Name: gtaion
Date: November 2, 2009 at 20:09:10 Pacific
Reply:

It's worth a try


0
Reply to Message Icon

Related Posts

See More


reding log file Unziping file and generat...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Batch file Encoder

Batch File to change the encoding www.computing.net/answers/programming/batch-file-to-change-the-encoding/19535.html

Batch file to copy and edit file www.computing.net/answers/programming/batch-file-to-copy-and-edit-file/16997.html

self destruct batch file ? www.computing.net/answers/programming/self-destruct-batch-file-/17288.html