CFLib.org – Common Function Library Project

createWEPKey([length])

Last updated September 21, 2004

Version: 1 | Requires: ColdFusion 5 | Library: SecurityLib

 
Rated 0 time(s). Average Rating: 0

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:

view plain print about
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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
29 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson