github.com/Ptt-official-app/go-bbs@v0.12.0/crypt/bbscrypt.go (about)

     1  package crypt
     2  
     3  import (
     4  	"errors"
     5  )
     6  
     7  var (
     8  	ErrInvalidCrypt = errors.New("invalid crypt")
     9  )
    10  
    11  //Fcrypt
    12  //Params
    13  //	key: the input-key (input-passwd) to be encrypted / checked
    14  //	salt: the salt (expected-passwd-hash) in crypt(3)
    15  //
    16  //Return
    17  //	[]byte: encrypted passwd, should be the same as salt if salt is the expected-passwd-hash.
    18  //  error: err
    19  func Fcrypt(key []byte, salt []byte) ([]byte, error) {
    20  	passwdHash := [PASSLEN]byte{}
    21  	cFcrypt(key, salt, &passwdHash)
    22  	return passwdHash[:], nil
    23  }