Electronic – arduino – Encryption Library for Arduino


I am using an Arduino to read a keypad and open an electric strike upon keypad PIN entry. For this sketch I wanted to use some sort of lightweight encryption to store the PINs in EEProm.
Does anyone know of such a library? I have heard it may be possible using TwoFish.

Best Answer

You don't want to encrypt passwords (PINs) -- you want to hash them. When someone enters a password, you hash that password, and compare the hash against the stored hash. The advantage to this method (used for over 30 years) is that even if someone gets hold of the source and the hashes, they still can't tell what PINs match the hashes, as long as you choose a strong enough hash function.

You don't want to implement encryption yourself -- you want to use someone else's library, particularly one with an open implementation that has been tested by a large community. Encryption is hard, testing is hard, and testing encryption is damned hard, so get someone else to do it for you.

You should checkout the AVR Crypto Library, which is licensed with GPLv3. There's also an implementation of Skein for AVR.