diff options
| author | Ryan Mehri <[email protected]> | 2020-05-15 19:00:21 -0600 |
|---|---|---|
| committer | Ryan Mehri <[email protected]> | 2020-05-15 19:00:21 -0600 |
| commit | 4e03758e92887fe4251a73ce8125b93e8624b6a2 (patch) | |
| tree | 7afe72a155fd9f6afd1bdded4a214b6fbba77fa0 /backend/db/db.go | |
| parent | Add encryption to content when password is specified (diff) | |
| download | ctrl-v-4e03758e92887fe4251a73ce8125b93e8624b6a2.tar.xz ctrl-v-4e03758e92887fe4251a73ce8125b93e8624b6a2.zip | |
Add comments and clean up encryption
Diffstat (limited to 'backend/db/db.go')
| -rw-r--r-- | backend/db/db.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/backend/db/db.go b/backend/db/db.go index b18eddf..df112d0 100644 --- a/backend/db/db.go +++ b/backend/db/db.go @@ -48,18 +48,18 @@ func New(ip, content, expiry, title, password string) (string, error) { // if there is a password, encrypt content and hash the password if password != "" { // use pass to encrypt content - key, salt, err := security.DeriveKey([]byte(password), nil) + key, salt, err := security.DeriveKey(password, nil) if err != nil { return "", fmt.Errorf("could not generate key: %s", err.Error()) } new.Salt = salt - encryptedBytes, err := security.Encrypt(key, []byte(new.Content)) + encryptedContent, err := security.Encrypt(key, new.Content) if err != nil { return "", fmt.Errorf("could not encrypt content: %s", err.Error()) } - new.Content = string(encryptedBytes) + new.Content = encryptedContent // hash given password hashedPass, err := security.HashPassword(password) |