Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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 xpsmeThat 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. :)
******************************************

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%abcdefghijklmnopqrstuvwxyzaset /p sentance=Enter your sentance:
set /a i = -1
:start
set /a i += 1For /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=

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
..etcThen 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. :)
******************************************

![]() |
reding log file
|
Unziping file and generat...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |