Batch file Encoder

Toshiba / Satellite m40
November 1, 2009 at 07:41:07
Specs: windows XP, 1.397 GHz / 958 MB
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 ?

Need help? Just ask. :)

See More: Batch file Encoder

Report •

November 1, 2009 at 19:59:00
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=%Alpha%abcdefghijklmnopqrstuvwxyza

set /p sentance=Enter your sentance:

set /a i = -1
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=

Report •

November 2, 2009 at 03:24:50
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.


SetLocal EnableDelayedExpansion
Set A=1
Set B=2
Set C=3

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 :-)

Need help? Just ask. :)

Report •

November 2, 2009 at 20:09:10
It's worth a try

Report •

Related Solutions

Ask Question