Skip to content

Instantly share code, notes, and snippets.

@yakuter
Created June 7, 2020 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yakuter/5ebbf480193581ec43b114588b08dc58 to your computer and use it in GitHub Desktop.
Save yakuter/5ebbf480193581ec43b114588b08dc58 to your computer and use it in GitHub Desktop.
PBKDF2 JS and Golang
import CryptoJS from 'crypto-js'
export default {
pbkdf2Encrypt(value) {
var salt = 'asdfghjkl'
const cipher = CryptoJS.PBKDF2(value, salt, {
keySize: 256 / 8,
iterations: 10000,
hasher: CryptoJS.algo.SHA256
})
// var key = CryptoJS.algo.PBKDF2.create({ keySize: keySize + ivSize, hasher: CryptoJS.algo.SHA256, iterations: 10 }).compute(password, salt);
return cipher.toString()
}
}
------------------
package main
import (
"encoding/hex"
"fmt"
"golang.org/x/crypto/pbkdf2"
)
func main() {
parola := "123456"
iter := 10000
length := 128
salt := "asdfghjkl"
yeni := pbkdf2.Key([]byte(parola), []byte(salt), iter, length, sha128.New)
fmt.Println(hex.EncodeToString(yeni[:]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment