Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old May 27th, 2005, 4:30 PM   #1
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 639
Rep Power: 4 Jessehk is on a distinguished road
"grid" encryptor

I don't know if any of you have read Digital fortress by Dan Brown, but he describes an ancient method of encrypting messages by using a square.

4 letters: test

they would be displayed like this:

T E
S T

and the encrypted message would be this: TSET.

I wanted to create a tool that would encrypt and decrypt these messages for me.

This is what I have so far, and it works. The decrypter will come later, this is simply the basis for the program.

note:the code only works if you enter in 4 letters or less. It will be updated however to accept up to 100 characters.



I'm sorry, I don't like comments. I'm too lazy :p ( I know, I know...bad habit).

Any questions or suggestions would be welcome.

#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main()
{
	int length, x, difference;
	char input[144];
	
	
	printf("Enter a phrase to be encrypted:");
	putchar('\n');
	gets(input);
	length = strlen(input);
	if(length <=4)
	{
		if(length > 0 && length < 4)
		{
			difference = 4 - length;
			for(x=0;x<difference;x++)
			{
				strcat(input,"*");
			}
			length = strlen(input);
		}
		for(x=0;x<length;x++)
		{
			if(!isalnum(input[x]))
			{
				input[x] = '*';
			}	
		}
		printf("\nHere is you encrypted text: %c%c%c%c", input[0],input[2],input[1],input[3]);
	}
	return(0);
}

Last edited by Jessehk; May 27th, 2005 at 4:36 PM.
Jessehk is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:47 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC