Thanks XDA-developers for the unlock codes for the Samsung Android devices, Galaxy S, Vibrant and Captivate. It seems that these codes are actually stored on device in a .BAK file on the internal SD card.
The only thing you have to do is to connect your Samsung device via USB and to drag the .BAK file into your desktop. Now run a script to extract the unlock code and you’re done. And this isn’t the only way. You can also choose to use a hex editor to locate the code or spend $10 and download the Galaxy S Sim Unlocker from Android market and the code will be automatically extracted.
And don’t worry if you have to return the device for some reasons, this process doesn’t require to root your phone, so your device can easily be re-locked.