Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,716 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,368 people online right now. Registration is fast and FREE... Join Now!




cryptography

 
Reply to this topicStart new topic

cryptography, encryption algorithm

duygugvn
post 27 Nov, 2005 - 11:25 AM
Post #1


New D.I.C Head

*
Joined: 31 Oct, 2005
Posts: 36


My Contributions


my functions are;
void encrypt(char sin[],char sout[],char key[];
void decrypt(char sin[],char sout[],char key[];
my encrypt function have to encrypt the input string sin using the public key key and return the encrypted string to sout.
my decrypt function have to decrypt the input string sin using the public key key and return the encrypted string to sout.ı determine the alphabet using array and calculata the codes of these strings using my alphabet.
I do not know how to use my alphabet in array????
User is offlineProfile CardPM

Go to the top of the page

Mrafcho001
post 27 Nov, 2005 - 12:39 PM
Post #2


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


a few problems there

if you gonna be editing the content of sout you better pass it as a reference.

also this seems to be better:

CODE

void encrypt(const char *sin, char *sout, const char *key);
void decrypt(const char *sin, char *sout, const char *key);

or
CODE

char* encrypt(const char *sin, const char *key);
char* decrypt(const char *sin, const char *key);

the pointer functions above will return a pointer to the memory where the encrypted/decrepted string is stored.

Also it is a lot better to pass pointers of strings to functions because the strings can be extrememly larg and you do not want to copy the string (slowing down the program), you just want to pass it to the function.

This post has been edited by Mrafcho001: 27 Nov, 2005 - 12:48 PM
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 27 Nov, 2005 - 12:58 PM
Post #3


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,163



Thanked 32 times

Dream Kudos: 25
My Contributions


Well, I'm not sure that answered the question...the user appears to be asking how to encrypt and decrypt using a supplied key.

Before going to deeply into this: duygugvn, are you supposed to be replacing the letters in the strings by letters or charcaters that are separated from the original by a certain number - the key?

As an FYI, arrays in C++ are always passed by reference.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 09:55AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month