473,883 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to write Wikipedia Caesar cipher ,please help!

2 New Member
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:"follow ed 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
char sen[100], x[100],k[100];
int i, num;

if((scanf("%s", &K1:)=="K1:" )
scanf("%0.1d",& num);}

for (i=0; i< strlen(sen); i++)

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

for (i=0; i< strlen(sen); i++)

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

return 0;
Nov 19 '06 #1
1 7735
2 New Member
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

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 using this library and to familiarise myself writing small tests with each of the ciphers. When I hit Crypto.Cipher.ARC4 I've
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 already which completes takes 1 and 2 but haven't got a clue with the conversion (task 3)
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 -> (*(^%&^GHJBBVvkek) odszyfrowanie (deszyfrowanie) - decrypting ( *^BNHJ*&% - > secret text) obsluga plikow - using files
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 great if any sample source code provided. Thanks, Sweety
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
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 as possible from users, so we encourage you to test the algorithm and send us your opinion. We would also like to receive enhancements and new versions of the algorithm, developed in other source languages and platforms. Our idea on developing...
by: thatos | last post by:
How can a progrsm caesar cipher using python
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: X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
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; cin.getline(inputfile, 81); char outputfile; cout << "enter output filename:"<<endl; cin.getline(outputfile, 81); string keyword;
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.