News for hackers. Stuff that matters.
Re:Copy and paste-friendly Go crypto by dawkins on Saturday July 16, 2016 @07:00PM (#12108203)
But what if I want to encrypt "my secret" with "password1234"?. You can't require everybody to memorize exactly 32 bit passwords
Re:Copy and paste-friendly Go crypto by wtbob on Saturday July 16, 2016 @08:24PM (#12108424)
As natedub indicates, to turn a password into a key you need to use a password-based key-derivation function; PBKDF2 is standardised, sane and reasonably quick; scrypt and bcrypt get more love these days, but I think any of them would be sufficient.

A cryptographic key (unlike a password) needs to be exactly a certain length, and ideally be completely random (if not, at least indistinguishable from random): a password might be exactly that length, but it will _not_ be completely random (heck, if you can type it then certain bit patterns simply won't occur …).

The fact that '012345789ABCDEF012345789ABCDEF' and unhex('cd8fa5ecf22379c429f56fdaae511144f9b7704247a244859b943299eb57fb1d') have the same length in bytes is coincidental; they really are two very different types.

Re:Copy and paste-friendly Go crypto by natedub on Saturday July 16, 2016 @07:11PM (#12108236)
Passwords are not keys, but you can generate a key from a password with a Password-Based Key Derivation Function.

See https://en.wikipedia.org/wiki/PBKDF2

Re:Copy and paste-friendly Go crypto by CiPHPerCoder on Saturday July 16, 2016 @07:09PM (#12108227)
Stop saying 32 bit, please. It's 32 byte, or 256 bit.

Furthermore, use a KDF to stretch your password into a key suitable for encryption.

Re:Copy and paste-friendly Go crypto by dawkins on Saturday July 16, 2016 @07:13PM (#12108241)
Sorry, of course I mean 32 byte.