The RWKG tool can be used to generate random WEP and WPA keys.
These randomly generated a strings of allowed ASCII characters are then converted to their hex format (where 5/13/16/29 characters are used to create 64/128/152/256 bits WEP keys, or between 8 and 63 characters strings to create WPA/PSK keys).
Code:
#!/usr/bin/perl
##
# RWKG
# Random WEP/WPA Keys Generator
#
# This tool generate a random string of
# allowed ascii characters and convert it
# to hex format (5/13/16/29 characters are
# necessary to create 64/128/152/256 bits
# WEP keys, 8-63 characters strings instead
# to create WPA/PSK keys).
#
# Code for SecurityWireless.info proof use only.
#
# Legal notes :
# BlackAngels staff refuse all responsabilities
# for an incorrect or illegal use of this software
# or for eventual damages to others systems.
##