Thread: Caeser Cipher

  1. #31
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Ahh i get you thanx for all of your help by the way.

  2. #32
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    Do you think i could do something like:
    for (int i = 0; i != alphabet_size; ++i)
          cyphertext += ( ( (plainchar[i] - '0' | 'A' | 'a') + shift) %) + '0' | 'A' | 'a';
          plainchar2 += cyphertext[i] - shift;
    But then i would be puzzeled about what goes after the modulus.

  3. #33
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    No, it could not be. How on earth is the compiler supposed to know when to use what?
    You need a function. Learn about functions. And you need the contents of the <cctype> standard header to classify characters.
    After the modulus you need the size of the class, i.e. 26 for alphabetic characters, 10 for digits.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #34
    Registered User L_U_K_E's Avatar
    Join Date
    Apr 2006
    It was just a guess really.I guess i could try read in each char 1 at a time and use its corrisponding type('a' | 'A' | '0').What do you think of that?
    Last edited by L_U_K_E; 06-28-2006 at 09:25 AM.

  5. #35
    Registered User
    Join Date
    Dec 2004
    Quote Originally Posted by L_U_K_E
    I sorted it anyway by just creating a new string and
        int alphabet_size = plainchar.length();

    And yes, for each character type you need to determine what kind of character it is and do the shift for that. Or you could Aplly to ceasar cypher to entiere ascii set (or better the entire ascii set apart from null), it wouldn't necessarily be printable but as far as the information stored goes it would work.

  6. #36
    Registered User
    Join Date
    Mar 2006
    Well, you'll need to test if a character is

    # 'a' to 'z'
    # 'A' to 'Z'
    # '0' to '9'

    And do a seperate dingo for each one. Again, when you decrypt (or more accurately decode), check if the character is

    # 'a'+3 to 'z'+3

    and so on.
    #include <stdio.h>
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Cipher Program
    By PunchOut in forum C Programming
    Replies: 7
    Last Post: 11-22-2008, 01:12 PM
  2. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  3. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  4. My little Caesar cipher emulator
    By dead_cell in forum C++ Programming
    Replies: 3
    Last Post: 01-16-2004, 01:05 AM