Click here to Skip to main content
15,891,184 members
Articles / Desktop Programming / Windows Forms

Drawing Names (A Christmas Name Drawing Application)

Rate me:
Please Sign up or sign in to vote.
4.78/5 (11 votes)
23 May 2012CPOL17 min read 67.1K   606   26  
A Christmas name drawing application using DHTML, JavaScript, XML, C#, Forms, VS2008, .NET 3.5, encryption.
	);
	var strPassPhrase = document.PassForm.strPass.value;
	var lenPassPhrase = strPassPhrase.length;
	var strPlainText  = strCrypt[ordName*2];
	var strSantaText  = strCrypt[ordName*2+1];
	var lenSantaText  = strSantaText.length;
	var lenPlainText  = strPlainText.length;
	var strMyAlphabet = "$Aa1Bb2Cc3Dd4Ee5Ff6Gg7Hh8Ii9Jj0Kk LlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";        
	var lenMyAlphabet = strMyAlphabet.length;
	var ordIllegalPassCharIndex = 1;
	var strNewPassPhrase = "";
	for (i=0;i<lenPassPhrase;i++)
	{   ordPassPhraseChar = strMyAlphabet.indexOf(strPassPhrase.charAt(i));
		if ((0==ordPassPhraseChar) || (-1==ordPassPhraseChar))
		{   ordPassPhraseChar = ordIllegalPassCharIndex++;
			if (ordIllegalPassCharIndex >= lenMyAlphabet)
			{   ordIllegalPassCharIndex = 1;
			}
		}
		strNewPassPhrase += strMyAlphabet.charAt(ordPassPhraseChar);
	}
	strPassPhrase = strNewPassPhrase;					//alert( strPassPhrase );

	var strCryptText  = "";
	for (i=0;i<lenPlainText;i++)        
	{   ordPassPhraseChar = strMyAlphabet.indexOf(strPassPhrase.charAt(i%lenPassPhrase));
		ordPlainTextChar  = strMyAlphabet.indexOf(strPlainText.charAt(i));
		ordCryptTextChar  = (ordPassPhraseChar ^ ordPlainTextChar) % lenMyAlphabet;
		strCryptText += strMyAlphabet.charAt( ordCryptTextChar );
	}
	document.OutputForm.strOutput.value = strCryptText;

	strCryptText  = "";
	for (i=0;i<lenSantaText;i++)        
	{   ordPassPhraseChar = strMyAlphabet.indexOf(strPassPhrase.charAt(i%lenPassPhrase));
		ordPlainTextChar  = strMyAlphabet.indexOf(strSantaText.charAt(i));
		ordCryptTextChar  = (ordPassPhraseChar ^ ordPlainTextChar) % lenMyAlphabet;
		strCryptText += strMyAlphabet.charAt( ordCryptTextChar );
	}
	document.SecretSantaForm.strSecretSanta.value = strCryptText;
}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
-- N/A --
United States United States
My educational background is Mathematics, Physics and Computer Science. I also earned a secondary teaching certificate.

My professional background is as a Software Engineer for the past 25 years or so and before that an instructor of Mathematics and Computer Science at the college level.

I currently design, develop, and support standards based Application Programming Interfaces that allow Windows based applications to interact with financial devices in a vendor neutral manner.

My hobbies are cycling, playing with the Internet, and reading.

Comments and Discussions