1
0
Fork 0
forked from jriou/coller

feat: Encode password

Fixes #38.

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2025-10-02 07:06:54 +02:00
commit de24146991
Signed by: jriou
GPG key ID: 9A099EDA51316854
7 changed files with 42 additions and 20 deletions

View file

@ -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
}