Skip to content

A small crypto package containing some useful utility functions

Notifications You must be signed in to change notification settings

wilfreddenton/crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

crypto

A small crypto package containing some useful utility functions

func GenKeyPair

func GenKeyPair() ([32]byte, [32]byte, error)

Generates a private and public key pair generated with the Curve25519 Diffe-Hellman function. Returns (privateKey, publicKey, error).

func GenSharedSecret

func GenSharedSecret(selfPri, otherPub [32]byte) [32]byte

Generates a shared secret with the client's private key and a peers public key using the [Curve25519] Diffie-Hellman function.

func Hash

func Hash(tag string, data []byte) []byte

Generates an authenticated 256 bit hash with the SHA-2 SHA-512/256 hash function in combination with HMAC.

func Encrypt

func Encrypt(plaintext []byte, secret [32]byte) ([]byte, error)

Returns an encrypted version of the provided plaintext using AES.

func Decrypt

func Decrypt(ciphertext []byte, secret [32]byte) ([]byte, error)

Returns a decrypted version of the provided ciphertext using AES.

References

About

A small crypto package containing some useful utility functions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages