Hi, encryption program

This is a discussion on Hi, encryption program within the C++ Programming forums, part of the General Programming Boards category; Well it also wouldn't work in a character set that didn't have contigious values for the alphabet. Loctan's function that ...

  1. #16
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Well it also wouldn't work in a character set that didn't have contigious values for the alphabet. Loctan's function that has the switch in it would probably be the most portable if the string only has lower case charactes.

  2. #17
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Loctan's function that has the switch in it would probably be the most portable if the string only has lower case charactes.
    Even then, it wouldn't take much to make it portable for both.

  3. #18
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    nope, it wouldn't. Though I would change the default to return the value instead of a space

  4. #19
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    >>I didn't know that you could treat the characters as integers

    Yes, instances of type char are just integers to your computer. The entire list of which integer represents which char is called a character set, examples of which are ASCII and Unicode, both of which are in common use in C++.

    Because char are integers you can encode messages by shifting any amount, by 1 or 2 or 7 or whatever, pretty readily, but the encoding process is not terribly difficult to break. Also, you need to determine how you handle end of alphabet situations. That is if the result after the shift is larger than 'z' or 'Z' or less than 'a' or 'A' do yo just display the char from the char set representing that integer value or do you wrap around to the beginning/end.

    You can also encode in such a way that there isn't a single shift but some irregular, but still definable pattern. Or you can put two sets of char into containers, randomly draw them out one at a time, and correlate one with the other. Or you can use some other "insanely" complicated process to encode your data. The general process is called mapping because there doesn't have to be a clear relationship (simple shifting, etc) between the input and the encoded message, as long as you can figure out/rely on the mapping process.
    You're only born perfect.

  5. #20
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    I agree with the irregular shift, if you only change 1 its barely encryption anymore. A scheme I made once took advantage of number seriess like fibannici numbers and the primes. You could shift by the product of each term along both secuences. The scheme I made was more complex then that though. Also, in loctan's code you need breaks at the end of each case.

  6. #21
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Also, in loctan's code you need breaks at the end of each case.
    Actually no it doesn't. Doing so would result in unreachable code.

  7. #22
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    What do you mean?
    I consulted the MSDN and it said that if you dont include the breaks it will run all options from the case to the end of the switch

  8. #23
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    You are correct, that without a break the control will fall through the cases. But he has returns. returns end the functions. If you had breaks after the returns then there would be no way to reach them.

  9. #24
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    doh!
    I knew that... =/

  10. #25
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    another thought... does it really matter if you overstep the alphabet in the encryption? the encrypted "string" is merely an array of integers and reversing the "algorithm" would give you correct values within the alphabet range. Surely it doesnt matter that the encrypted string contains characters beyond the alphabet? And what if you wanted to have special characters in you string like ''?

    Just a thought
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

  11. #26
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515
    u can do some algo of this sort...
    1.take in the what the user wants to encrypt
    2.generate an array which contains the new character set ,the ones used for encryption
    3.find the length of the string the user has entered
    4.replace every character in the string with one in your character set.
    5.print it on the screen or store it in a file.

    to implement it in c++ is up to u now..
    and guys plz dont post entire codes.programming be understood by doing it ourselves.you are not helping the guy a bit by postin entire codes.takes the fun out of programming.

  12. #27
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    DominicTrix, to answer your question it can matter as far as portability goes. Not all character setups will have the same stuff around the values that represent the characters. So lets say 'z' is 35 on a system and the next character is '|'. But on some other system 'z' is 65 which isn't a problem but the next character is '&' and '|' is before 'a'. Now we have a problem.

    Note: Character values made up on the fly. They do not intentionally represent any known character set.

  13. #28
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    Hmmm, but surely any text written on one system and then opened in the other (with different char set will be displayed incorrectly?
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

  14. #29
    Registered User
    Join Date
    Nov 2004
    Location
    India
    Posts
    515
    Quote Originally Posted by DominicTrix
    Hmmm, but surely any text written on one system and then opened in the other (with different char set will be displayed incorrectly?
    well,you will have to pass the original cypher wont you??and i dont think that treating the individual letters as char type,and then after passing the cypher as well,there is going to be any portability problem.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Encryption Program (help me please)
    By Arkanos in forum Windows Programming
    Replies: 7
    Last Post: 10-30-2005, 08:01 PM
  2. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 08:51 AM
  3. Basic encryption program???
    By Finchie_88 in forum C++ Programming
    Replies: 14
    Last Post: 09-10-2004, 10:01 AM
  4. Replies: 2
    Last Post: 05-10-2002, 05:16 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21