feat: replace sha1 to sha512 in pbkdf2.Key function

This commit is contained in:
Adrien Waksberg 2019-07-20 17:18:52 +02:00
parent fb0e36b050
commit 09445236a4
2 changed files with 4 additions and 3 deletions

View file

@ -17,6 +17,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
- Prefix error message with ERROR
- Fix new line with clear input
- Replace sha1 to sha512 in pbkdf2.Key function
## v1.0.0 - 2019-07-12

View file

@ -16,7 +16,7 @@ package gpm
import(
"crypto/aes"
"crypto/sha1"
"crypto/sha512"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
@ -29,7 +29,7 @@ import(
// Encrypt data with aes256
func Encrypt(data []byte, passphrase string, salt string) (string, error) {
key := pbkdf2.Key([]byte(passphrase), []byte(salt), 4096, 32, sha1.New)
key := pbkdf2.Key([]byte(passphrase), []byte(salt), 4096, 32, sha512.New)
block, err := aes.NewCipher([]byte(key))
if err != nil {
@ -54,7 +54,7 @@ func Encrypt(data []byte, passphrase string, salt string) (string, error) {
// Decrypt data
func Decrypt(data string, passphrase string, salt string) ([]byte, error) {
key := pbkdf2.Key([]byte(passphrase), []byte(salt), 4096, 32, sha1.New)
key := pbkdf2.Key([]byte(passphrase), []byte(salt), 4096, 32, sha512.New)
rawData, err := base64.StdEncoding.DecodeString(data)
if err != nil {