Under the Bridge

Secure Credentials

If you store any kind of password in your app, you should stop doing that and read this article:

Storing and testing credentials: Cocoa Touch Edition

There’s been quite the media circus regarding the possibility that Sony was storing authentication credentials for its PlayStation Network credentials in plain text. I was even quoted in a UK national daily paper regarding the subject. But none of this helps you: how should you deal with user passwords? …

… The important point is that you never need to see that password—you need to know that the same password was presented in order to know (or at least have a good idea) that the same user is at the touchscreen, but that’s not the same as seeing the password itself.

That means that we don’t even need to use encryption where we can protect the password and recover it when we must check the password. Instead we can use a cryptographic one-way hash function to store data derived from the password: we can never get the password back, but we can always generate the same hash value when we see the same password.

Shut up Graham. Show me the code.

Here it is. This code is provided under the terms of the WTFPL

Much easier to implement now than try to explain why you didn’t later, indeed.

We rather like the license, too. Next time we get around to open sourcing something of our own, most assuredly we will use the WTFPL to do so!