Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.bat file create a cyher program

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
520
US
Hi all,

I am attempting to learn .bat and am trying to create a program to take a sentence, convert it into a number code, then be able to convert it back like a cypher and code breaker. I have gotten most of the program started, but the only sections that I am missing are how to import the sentence back into .bat so that it can be converted.

here is what I have at this time. I am thinking that the commands that I will need is the TYPE command to read the cypher file. How do I then save it as a variable value?

Thanks for the help,

Mike

Code:
@echo off
title Cypher Program
cls

:: This program will convert simple text to a random code and back again with a specific number as the cypher generator

:: number = input value for multiplier
:: sentence = origional text
:: ccode = converted code

:: Menu is the section to select the convert to code or unscramble code

::___________________________________

:menu
color 7
cls
echo _____________________
echo.
echo    Select Process
echo _____________________
echo.
echo (1) Create new Cypher
echo (2) Solve a Cypher
echo _____________________
echo.

set /p var=Run:

IF '%var%' == '1' goto sentence
IF '%var%' == '2' goto ccode
IF '%var%' LSS '0' goto menusel

::___________________________________

:menusel
cls

echo The option that you selected is invalid.  Please select a valid option.

ping 1.0.0.0 -n 1 -w 3500 >NUL

goto menu

::___________________________________

:sentence
cls
echo _____________________
echo.
echo    Create Cypher
echo _____________________
echo.
echo (1) Enter Magic #
echo (2) Enter Sentence
echo (3) Cypher Generated
echo _____________________
echo.
echo (R) Main Menu
echo _____________________
echo.

set /p magic=Magic Number:

IF '%magic%' == 'R' goto menu
IF '%magic%' == 'r' goto menu
IF '%magic%' GTR '0' goto imputsent
IF '%magic%' LEQ '0' goto magerror

::___________________________________

:magerror
cls
color 6

echo The number entered in not greater that 0.  Please enter a number greater than 0.

ping 1.0.0.0 -n 1 -w 3500 >NUL

color 7
goto sentence

::___________________________________

:imputsent

cls
echo _____________________
echo.
echo    Imput Sentence
echo _____________________
echo.
echo.
echo Please enter your Text
echo.
set /p sent=Sentence:     

goto cypherout


::___________________________________

:cypherout
cls
echo _____________________
echo.
echo   Generated Cypher
echo _____________________
echo.
echo.
echo Origional Text:
echo.
echo %sent%
echo.
echo.
echo Cypher:
echo.
::echo %output%
echo.
echo Save Origional Sentence?
set /p saveorig=(Y/N?):

IF '%saveorig%' == 'y' goto rawtext
IF '%saveorig%' == 'Y' goto rawtext
IF '%saveorig%' == 'n' goto cypsave
IF '%saveorig%' == 'N' goto cypsave

::___________________________________


:rawtext
cls
echo Name your Origional Sentence File
set /p origfile=File Name:
echo %sent% > "%origfile%".txt

::___________________________________

:cypsave
cls
echo Name your Cypher File

:: Place holder lines
set /p cypherfile=File Name:

echo %sent% > "%cypherfile%".txt


cls
color 6
echo Cypher Created and Saved

ping 1.0.0.0 -n 1 -w 3500 > NUL

color 7

goto menu 

pause

::___________________________________

:ccode
cls
echo _____________________
echo.
echo     Import Cypher
echo _____________________
echo.
echo (1) EnterMagic #
echo (2) Select Cypher
echo (3) Decrypt Cypher
echo _____________________
echo.
echo Please imput the Magic Number
echo.
set /p magic=Magic Number:

IF '%magic%' == 'R' goto menu
IF '%magic%' == 'r' goto menu
IF '%magic%' GTR '0' goto cyffilein
IF '%magic%' LEQ '0' goto magerror2

::___________________________________

:magerror
cls
color 6

echo The number entered in not greater that 0.  Please enter a number greater than 0.

ping 1.0.0.0 -n 1 -w 3500 >NUL

color 7
goto ccode

::___________________________________

:cyffilein

echo Please enter file name for your Cypher
echo.
echo set /p cypherfile= File Name:



::___________________________________

IF '%cypherfile%' GEQ '0' goto decrypt

::___________________________________

:decrypt

set /p code '%cypherfile%'= type decryptxt 

print decryptxt

pause
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top