There are third party providers online who offer to remove the SIM lock on mobile phones, by emailing the unlock code. All they ask for is the phone's IMEI and the network provider's name.
In one case, one provider came back after 24 hours to say he can't do it. Another provider delivered the unlock code in about 24 hours. The unlock code was eight digits.
That the first provider failed and the process takes time suggests to me that it's not a completely straightforward process.
Also, as they are not in physical possession of the phone when unlocking suggests that it's not a hardware hack. (And not brute force?)
I saw mentions of a "database".
How does this all work?