CFLib.org – Common Function Library Project

createWEPKey([length])

Last updated September 21, 2004

author

Alan McCollough

Version: 1 | Requires: CF5 | Library: SecurityLib

Description:
Creates a 40-bit or 128-bit WEP key. Use entirely at your own risk. No security is implied or provided by using this. This function simply creates a key for you.

Return Values:
Returns a string.

Example:

createWEPKey(40) returns: B053D17A22
createWEPKey(128) returns: DAB9CF62B96D59DC0883A3AEA8
createWEPKey() returns: A156F82F5374722B6E1ADEB32B

Parameters:

Name Description Required
length Length of the WEP key. Either 40 or 128 (default). No

Full UDF Source:

/**
 * Creates a 40-bit or 128-bit WEP key.
 * 
 * @param length 	 Length of the WEP key. Either 40 or 128 (default). (Optional)
 * @return Returns a string. 
 * @author Alan McCollough (amccollough@anmc.org) 
 * @version 1, January 12, 2006 
 */
function createWEPKey() {
	var baseKey = "";
	var key = "";
	var defaultLength = 128;
	var length = defaultLength;
	
	/* If user has passed in a specfic key length, and they want a 40-bit key,
	change the value of length to 40 instead of 128.
	Of course, a 40-bit WEP key is trivial to crack, but that is not my problem. */
	if (arrayLen(arguments) eq 1) {
		if(val(arguments[1]) eq 40)
			length = 40;
	}
	
		
	/* 
		CF generated UUIDs look like this:
		73B96C47-F5F1-0F5C-488C7C5170101FA0
		8 chars - 4 chars - 4 chars - 16 chars
		
		First off, generate a base key
	*/
	baseKey = mid(createUUID(),20,16) & mid(createUUID(),15,4) & mid(createUUID(),10,4) & mid(createUUID(),25,2);
	
	/* Create a 40-bit or 128-bit key, as the user requested */
	switch(length) {
		case "40": {
			key = mid(baseKey,10,10);
			break;
		}
		case "128": {
			key = baseKey;
			break;
		}
	} //end switch
	
	return key;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson