secure key generation

This commit is contained in:
Henrique Dias committed 2017-07-25 09:01:29 +01:00
1 parent cc6652c8a0
commit eb01267643
2 files changed
+20 -12

No files matched your search

+7 -1
View File
@@ -163,7 +163,13 @@ func New(database string, base User) (*FileManager, error) {
// If it doesn't exist, create a new one of 256 bits.
err = db.Get("config", "key", &m.key)
if err != nil && err == storm.ErrNotFound {
m.key = []byte(randomString(64))
var bytes []byte
bytes, err = generateRandomBytes(64)
if err != nil {
return nil, err
}
m.key = bytes
err = db.Set("config", "key", m.key)
}