The only thing is that you have to pay for the locker. At least in my city, at the train station, you get a receipt with a barcode that you scan later. If we're talking specifically about
phone charging solutions, they usually use a PIN code, and the security comes from the fact that the PIN is created by the person who owns the phone. The system doesn’t generate it for you. If you're really concerned about security, try asking the companies that provide these charging lockers and solutions for more details.