3 Replies - 2033 Views - Last Post: 20 September 2009 - 07:35 AM Rate Topic: -----

#1 Wolf CCMLG   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-September 09

Help with String Encryption Class

Post icon  Posted 20 September 2009 - 01:18 AM

I really need help with this programming challenge that I have to do. I have no idea what to do, if someone could get me started on the right path, I would greatly appreciate it.

Here are my instructions:

Write a class EncryptableString that is derived from the STL string class. The EncryptableString class adds a member function

void encrypt( )

That encrypts the string contained in the object by replacing each letter with its successor in the ASCII ordering. For example, the string baa would be encrypted to cbb. Assume that all characters that are part of an EncryptableString object are letters a..z and A...Z, and that the successor of z is a and the successor of Z is A. Test your class with a program that asks the user to enter strings that are then encrypted and printed.

I don't know what the STL string class is, nor do I know how to encrypt a string by modifying it via ASCII characters. :blink:

This post has been edited by Wolf CCMLG: 20 September 2009 - 11:27 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Help with String Encryption Class

#2 poncho4all   User is offline

  • D.I.C Head!
  • member icon

Reputation: 123
  • View blog
  • Posts: 1,422
  • Joined: 15-July 09

Re: Help with String Encryption Class

Posted 20 September 2009 - 06:13 AM

STL means Standard Template Libraries. They are refering to the library string
Was This Post Helpful? 0
  • +
  • -

#3 aks29921   User is offline

  • D.I.C Regular

Reputation: 116
  • View blog
  • Posts: 345
  • Joined: 24-August 09

Re: Help with String Encryption Class

Posted 20 September 2009 - 07:21 AM

as poncho4all said, u hv to use string types....

for each character in the string, you can get its ascii value, increment the ascii value by one(check, if it is 90 or 122, make it 65 or 97 respectively) and then print the corresponding character from the new ascii value...
ascii value of A=65,B=66 and it goes on upto Z=90
ascii value of a=97.....z=122
to convert a character to its ascii value, simply equate the character with an integer variable, the int variable will automatically take the ascii value
similarly equate the integer value to a character variable to get the corresponding character from its ascii value.

that's all you have to do, hope u get a nice start.

ny mods reading this, i think this topic gotta be the 'beginner' type

This post has been edited by aks29921: 20 September 2009 - 07:37 AM

Was This Post Helpful? 0
  • +
  • -

#4 gabehabe   User is offline

  • GabehabeSwamp
  • member icon

Reputation: 1433
  • View blog
  • Posts: 11,006
  • Joined: 06-February 08

Re: Help with String Encryption Class

Posted 20 September 2009 - 07:35 AM

This is known as a caesar cipher.

It's actually really simple to implement:

You'll have to tweak it so that it adjusts the actual member content from your string class, but you get the idea. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1