createWEPKey([length])
Last updated September 21, 2004
Version: 1 | Requires: ColdFusion 5 | 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(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:
<cfscript>
/**
* 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;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
11 day(s) ago
Will Belden added
longTime
17 day(s) ago
James Sleeman added
quickSort
27 day(s) ago
Ben Forta added
GetHostAddress
29 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)