forked from jriou/coller
feat: Encode password
Fixes #38. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
f721e56371
commit
de24146991
7 changed files with 42 additions and 20 deletions
|
@ -123,7 +123,7 @@ func (d *Database) Get(id string) (*Note, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *Database) Create(content []byte, password string, encryptionKey string, encrypted bool, expiration int, deleteAfterRead bool, language string) (note *Note, err error) {
|
||||
func (d *Database) Create(content []byte, password []byte, encryptionKey string, encrypted bool, expiration int, deleteAfterRead bool, language string) (note *Note, err error) {
|
||||
if expiration == 0 {
|
||||
expiration = d.expiration
|
||||
}
|
||||
|
@ -161,8 +161,8 @@ func (d *Database) Create(content []byte, password string, encryptionKey string,
|
|||
note.Encrypted = true
|
||||
}
|
||||
|
||||
if password != "" {
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
if password != nil {
|
||||
hash, err := bcrypt.GenerateFromPassword(password, bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue