Quick Search for:  in language:    
Encrypts,string,using,another
   Code/Articles ╗ |  Newest/Best ╗ |  Community ╗ |  Jobs ╗ |  Other ╗ |  Goto ╗ | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 715,766. lines
 Jobs: 107. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for C/ C++.
Click here to see a screenshot of this code!c++ basic all
By Hamdi Farah on 1/28

(Screen Shot)

biopro.c --- search for words that do not exist in the dictionary file
By Donald Bono on 1/28


BruteForce Engine
By koby-GR on 1/28


Catch Me If U Can !!
By ashish & manas on 1/27


nOS ver 1.0
By - Snake - on 1/27


WordInFile.c -- look up a dictionary file for the word you just entered (source code only)
By Donald Bono on 1/27


WordInList.EXE -- search a dictionary file (included)
By Donald Bono on 1/27


Alymars Dice Roller
By roy sawyer III on 1/26


LCI_EXPORTER
By Leandro Pelorosso on 1/26


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

YoshiCrypt

Print
Email
 
VB icon
Submitted on: 11/23/2003 10:13:05 PM
By: Jason W. Kielpinski  
Level: Intermediate
User Rating: Unrated
Compatibility:C, C++ (general), UNIX C++

Users have accessed this code 420 times.
 
(About the author)
 
     Encrypts a string using another string as a key
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

//**************************************
//     
//INCLUDE files for :YoshiCrypt
//**************************************
//     
stdio.h
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: YoshiCrypt
// Description:Encrypts a string using a
//     nother string as a key
// By: Jason W. Kielpinski
//
// Inputs:the key and then the to be enc
//     rypted string
//
// Returns:the encrypted string
//
// Assumes:should work with any length s
//     tring
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/vb/scripts/Sh
//     owCode.asp?txtCodeId=7156&lngWId;=3//for details.//**************************************
//     

/*
An encryption program based on the vigerne algorithm
By: Jason Kielpinski
http://y0shi.sytes.net
defiant_penguin@cox.net
*/
#include <stdio.h>
const char alphabet[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()-_=+[{]}\\|;:\'\",<.>/? ";
int encstr(char *, char *);
int alph_create(char, char *);
int getalphpos(char);
    int main(int argc, char **argv) {
    	/*Check arguments*/
        	if (argc < 3) {
        		printf(	"YoshiCrypt v1.0 Usage:\n"
        					"\t%s [keyword] [to_be_encrypted_string]\n", argv[0]);
        	}
        	char *key = (char *)malloc(sizeof(argv[1]));
        	int x = argc - 2;
        	int len;
            	for (x; x<argc; x++) {
            		len += strlen(argv[x]);
            	}
            	char *string = (char *)malloc(sizeof(char [len]));
            	bzero(key, sizeof(key));
            	bzero(string, sizeof(string));
            	sprintf(string, "%s", argv[2]);
                	for (len = 3; len < argc; len++) {
                		sprintf(string, "%s %s", string, argv[len]);
                	}
                	sprintf(key, "%s", argv[1]);
                	encstr(key, string);
            }

int encstr(char *key, char *string) { /*Prepare the encrypted alphabet buffer*/ char encalph[strlen(key)][strlen(alphabet)]; char tempalph[strlen(alphabet)]; int x, y, keylen, inplen; int letpos; keylen = strlen(key); inplen = strlen(string); char encstr[inplen]; bzero(encalph, sizeof(encalph)); bzero(encstr, sizeof(encstr)); /*Get encryption table*/ for (x=0; x < keylen; x++) { bzero(tempalph, sizeof(tempalph)); alph_create(key[x], tempalph); sprintf(encalph[x], "%s", tempalph); } y = 0; for (x=0; x <= inplen-1; x++) { letpos = getalphpos(string[x]); /*If alphabet letter, print to encstr, else keep original*/ if (letpos != -1) { sprintf(encstr, "%s%c", encstr, encalph[y][letpos]); } else { sprintf(encstr, "%s%c", encstr, string[x]); } if (y == keylen-1) { y = 0; } else { y++; } } printf("%s\n\n", encstr); return 0; }
int alph_create(char start, char *alph) { int x, y; /*Get start len*/ for (x=0; alphabet[x] != start; x++) {} /*Get first part of alphabet*/ for (y=x; y <= strlen(alphabet); y++) { sprintf(alph, "%s%c", alph, alphabet[y]); } /*Get second part of alphabet*/ for (y=0; y < x; y++) { sprintf(alph, "%s%c", alph, alphabet[y]); } return 0; }
int getalphpos(char let) { int pos; for ( pos=0; alphabet[pos] != let && pos <= strlen(alphabet); pos++ ) {} if (pos >= strlen(alphabet)) { return -1; } return pos; }
/*EOF*/

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyrightę 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.