INNER CODE UNIT · Go

Encrypt

cryptag/cryptag · encrypt_decrypt.go:27

func Encrypt(plain []byte, nonce *[24]byte, key *[32]byte) ([]byte, error) {
	if nonce == nil {
		return nil, ErrNilNonce
	}
	if key == nil {
		return nil, ErrNilKey
	}

	cipher := secretbox.Seal(nil, plain, nonce, key)
	return cipher, nil
}

func Decrypt(cipher []byte, nonce *[24]byte, key *[32]byte) ([]byte, error) {
	if nonce == nil {
		return nil, ErrNilNonce
	}
	if key == nil {
		return nil, ErrNilKey

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…