Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

help with Caesar cipher ,thx thx thx(urgent)

beetle17beetle17 Posts: 2Member
[b][red]This message was edited by beetle17 at 2006-11-20 8:31:30[/red][/b][hr]
[b][red]This message was edited by beetle17 at 2006-11-20 8:24:43[/red][/b][hr]
l just learn C program not long time ago,it is too diffcult for me to write a cipher

(Plaintext : a nice day)
(Key : -3)
(Ciphertext : X kfZb aXv)

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 like dogs
C i p h e r t e x t is < L olnh grjv >
D 1: L olnh grjv
P l a i n t e x t i s < I like dogs >
E 1: H e l l o
C i p h e r t e x t i s < Khoor >

Example II of Cipher:
E 1: I like dogs
K e y not found
K 1: -54
E 1: Hello
C i p h e r t e x t is < Fcjjm>
K 1: h h h h
Invalid K e y






Comments

  • beetle17beetle17 Posts: 2Member
    [b][red]This message was edited by beetle17 at 2006-11-20 23:38:22[/red][/b][hr]

    l am typeing a program about cipher ,
    to make the result:
    Example I of Cipher:
    input K 1: 3
    //P l a i n t e x t  i s < I  l i k e  d o g s >
    input E 1: I  l i k e  d o g s
    //Ciphertext is < L  o l n h  g r j v >
    output D 1: L o l n h g r j v
    input K 1: h h h h
    putput Invalid  K e y

    where K1: , D1: ,E1: are 3 different command,
    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.

    l want to ask how could l write to separate K1: , D1: ,E1:from the input string,to let make appling different function on different command.

    l only write
    #include
    #include
    main()
    {
    char sen[100], x[100],k[100];command[]={'sen[0]','sen[1]','sen[2]',''}
    int i, key;
    gets(sen);
    switch(command[]){
    case "K1:":
    function A;
    case "D1:":
    function B;
    case "E1:":
    function C;
    default:
    printf(input error)
    }
    is it Ok?


Sign In or Register to comment.