473,378 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to write Wikipedia Caesar cipher ,please help!

Plaintext: a  n i c e  d a y
Key: -3
Ciphertext: X  k f Z b  a X v

Cipher will accept commands from the user and perform the operations required by the commands. There are three different commands. Key command starts with "K1:"followed by a string as the key. Encryption command starts with "E1:" followed by the plaintext. Decryption command starts with "D1:" followed by the ciphertext to be decrypted. After the user inputs an encryption (or decryption) command, Cipher1 should encrypt the plaintext (or decrypt the ciphertext) using the key input by a previous key command, and print the results. The error message "key not found" should be printed if the user inputs an encryption or decryption command before a key command. If the user
inputs multiple keys, the latest key will be used in the following encryption/decryption operations. Below are two examples (underlined text is the input from the user, and italic text is the output of Cipher).
When the plaintext/ciphertext includes non-letter symbols, Cipher1 will ignore them.For example, a plaintext of "No. 2" is equivalent to "No".

Example I of Cipher:
K 1: 3
E 1: I  l i k e  d o g s
C i p h e r t e x t  i s < L  o l n h  g r j v >
D 1: L  o l n h  g r j v
P l a i n t e x t  i s < I  l i k e  d o g s >
E 1: H e l l o
C i p h e r t e x t  i s <K h o o r>

Example II of Cipher:
E 1: I  l i k e  d o g s
K e y  n o t  f o u n d
K 1: -54
E 1: H e l l o
C i p h e r t e x t  i s <F c j j m>
K 1: h h h h
Invalid  K e y

l just learn C program not long time ago,it is too diffcult for me to write,please tell me how it is

l writed only
main()
{
char sen[100], x[100],k[100];
int i, num;

if((scanf("%s",&K1:)=="K1:")
{gets(sen);
printf("E1:");
scanf("%0.1d",&num);}

for (i=0; i< strlen(sen); i++)
x[i]=sen[i]-num;


if((scanf("%s",&D1:)=="D1")&&scanf("%d",&num))
scanf("%0.1d",)
printf("D1:%s\n",x);

for (i=0; i< strlen(sen); i++)
x[i]=x[i]+num;

printf("%s\n",x);

return 0;
}
Nov 19 '06 #1
1 7709
maybe ,
could anyone tell me what function should l use in this program?
Nov 20 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Michael Sparks | last post by:
Hi, I suspect this is a bug with AMK's Crypto package from http://www.amk.ca/python/code/crypto , but want to check to see if I'm being dumb before posting a bug report. I'm looking at...
4
by: Carl Harris | last post by:
I am trying to write some code to: 1.Prompt a user for filenames 2.Open the files 3.Convert my plain text into a cipher text array/string bear in mind I am a novice! I have wriiten some code...
9
by: Piotr Turkowski | last post by:
Hi, The code is here: http://free.ud.pl/~piotr/data/vigenere.zip Its my program for decrypting and encrypting text. Shot polish course: szyfrowanie (szyfruj) - encrypting (text i want to code...
9
by: sweety | last post by:
Dear All, How to encrypt a C data file and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data. Any help to achive this pls. Would be...
24
by: Luis M. González | last post by:
For those interested in the simplest, easiest and most pythonic web framework out there, there's a new page in Wikipedia: http://en.wikipedia.org/wiki/Karrigell
2
by: Julio C. Hernandez Castro | last post by:
Dear all, We have just developped a new block cipher called Raiden, following a Feistel Network structure by means of genetic programming. Our intention now consists on getting as much feedback...
2
thatos
by: thatos | last post by:
How can a progrsm caesar cipher using python
0
by: ntuyen01 | last post by:
Hi all, I want to use the SSLStream with the cipher (TLS_RSA_WITH_AES_128_CBC_SHA) to get the handshake with my server, but I not sure where I can start. I do it in C# 2.0 Here is my code: ...
1
by: ckking | last post by:
ok the part that i had earlier was supposed to part of this cipher, im having trouble with it not converting spaces char ch; char inputfile; cout << "enter input filename:"<<endl;...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.