1. ## Character Tables ( Password Encryption )

Hey peoples!

Sorry, I'm back again. I realize that there was a recent thread about password encryption, so I do apologise for creating another. But I was reading that thread, and I read about a sort of "table of characters" method of encryption that I wanted to try. I understand the concept, but I don't know how it can be implemented. I started my function (well bool to be exact,) to simply take a string, go through it character by character, and based on the table, change it into it's designated symbol/number/letter. In my case, number. Then I intend to convert it to an int, and preform some mathematical calculations on it.

How can this be achieved?
Thanks for any future replies or any useful information you can provide.

2. So what's so hard about
Code:
```struct foo {
char clear;
char cypher;
} table[] = {
{ 'a', 'z' },
{ 'b', 'y' },
{ 'c', 'x' },
// etc
};```
Then having a for loop to match table[ i ].clear, and return table[ i ].cypher

3. ## Um ...

Okay. I understood you until the table part. What does table[] mean? Where did table[ i ] come from? What's the difference between:
Code:
``` { 'a', 'z' }

// and

a = z ?```
Just F.Y.I. I'm a total noob.
Sorry for my annoyingly persistant questions.

EDIT:

Oh, plus I do not know how to tell it to read one character at a time, so I don't know what condition to use in the loop.

4. You get 'i' from a for loop, which examines each entry in the array which is called table.

As in
for ( i = 0

5. ## Arrays

Never worked with arrays before. It says:
Code:
` table[] undeclared (first use this function)`
How do I specify that it's an array?

Cheers for the replies Salem.

6. I showed you how to initialise the array.
You need to post more code if it isn't working out.

7. ## Ok. I got this so far:

Code:
```#include <string>

bool EncryptString ( string StringName )
{
struct Encryption_Variables
{
char clear;
char cypher;
}

Table[] =
{
{'a', '162806'},
{'b', '100615'},
{'c', '62191'},
{'d', '38424'},
{'e', '23767'},
{'f', '14657'},
{'g', '9110'},
{'h', '5547'},
{'i', '3563'},
{'j', '1984'},
{'k', '1597'},
{'l', '987'},
{'m', '610'},
{'n', '377'},
{'o', '233'},
{'p', '144'},
{'q', '89'},
{'r', '55'},
{'s', '34'},
{'t', '21'},
{'u', '13'},
{'v', '8'},
{'w', '5'},
{'x', '3'},
{'y', '2'},
{'z', '1'},
};

}```
I get some errors saying: [Warning] character constant too long for its type.

(26 to be exact. One for each letter.)

I also get these: Line 3. `string' was not declared in this scope.

And: Line 3. syntax error before `)' token.

I understand the first error, but don't know how to fix it, and I don't understand the last two errors. Any help you could lend would be great. Cheers.

8. > 'a', '162806'
Why so many characters?
Or are these really numbers?

You have two choices
1. make std::string cypher and have "162806"
2. make int cypher and have 162806

9. make std::string cypher and have "162806"
In this case the encoded strings should be also reconsidered...

"13" cannot be uniquly decoded because it represents 2 possible sequences "u" or "zx", for example

10. the single quote ' is for a char

ie 'a'

your number in the single quote is that suposed to be char string or a number? like salems struct
Code:
```struct foo {
char clear;
char cypher;
} table[] = {
{ 'a', 'z' },
{ 'b', 'y' },
{ 'c', 'x' },
// etc
};```
one char for one place in the table[a] variable.
if you want to use number you have to use int and not char unless you want a string "this is a string" note the double quotes that you would use in your struct.

{ "string1" , "string2" } .... and so on....

edit
what type of encryption?

11. Originally Posted by Salem

You have two choices
1. make std::string cypher and have "162806"
2. make int cypher and have 162806
Apoligies for my incompetence, but I'm not sure I follow you. Basically, I want the function to read the first character into a string. Then I wish for it to look in the table (not literally, that would be hard to do,) for the number opposite it, and place that in another string. And then do the same with the rest of the characters.

Also about the unique decoding flaw, would putting a period after each section of numbers help? So if the origional string was: Hello, the encoded string would look like this:

5547.23767.987.987.233

A bit like an IP address.
Thanks again for replies!

EDIT:

What do you mean by: What type of encryption?

12. Also about the unique decoding flaw, would putting a period after each section of numbers help?
It would... But why to bother with the long strings in this case? There are 26 (or 255) literals in your encoded string that are easely determined by this points using the long enough encoded sequense... If you're going to provide this knolegde to the one trying to hack your mechanism why not just to go on the simple choice - one symbol is replaced by one symbol (as was suggested in the beggining)?

13. > If you're going to provide this knolegde to the one trying to hack your mechanism why not just to go on the simple choice ect

I didn't know I was going to provide this knowledge to the one trying to hack my mechanism. Why would I? Or am I already?

Confused???

14. I thought you're going to store the encrypted passwords somethere they can be easely (or not so easely) read? Why else you're bother to encript them?

So someone looking on your list of encripted passwords and fingdings these intresting points inbetween your encripted letters can easely determine that actually only 26 different strings are present in the file... Or maybe its just my imagination...

15. Oh I get you.

Surely they won't be able determine how many strings are used if there are only say 7 sections of numbers in the file. If I gave you:

610.233.377.1597.23767.2.34

how would you know I was using thew first 26 terms of the fibonaci (sp?) sequence?