Since iPhone OS 2iOS 4.0, there's supports a very rapid secure erase called "Data Protection". If you upgrade from 3.0 you need to do a restore to set the stage for hardware encryption of all the data.
If your device isn't capable of hardware encryption (often called secure data at rest), then you can use the Erase all content and settings function. This built-in functionality to secure wipe your iDevice has been around since iPhone OS 2.0
BUT this has notAs this doesn't work the same way the same effect on all iDevices !
You should really have a look on Apple page aboutiOS devices, do read Understanding 'Erase All Content and Settings' before you depend on this to clear data securely.
Once you are through erasing the device, you might want to connect it to a clean iTunes library and restore the device and set it up as new. Making a new account on your Mac or PC is an easy way to have a library with no account, no songs, and no apps just to be sure the device has a clean (and easily verifiable) start to it's new life.