Lenny's universal KeyGen