wpa_passphrase YOUR_SSID YOUR_PASSPHRASE > /etc/wpa_supplicant.conf
If you're using WPA2/AES, it should loook something like this:
psk=(lots of gibberish)
(You have to add some lines yourself)
If you're using TKIP, the pairwise, proto, and/or group lines will be different, but I can't remember how ATM. They may not even be necessary.
I've also had issues connecting to a non-SSID-broadcasting network, so you may have to change that.