licrypt

package module
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2024 License: GPL-3.0 Imports: 0 Imported by: 0

README

Licrypt

  • Symmetric cryptography made easy
  • Securely encrypt and decrypt
  • Data authenticity and integrity
  • Performant: 400ns/op & 8 allocs tested in parallel
Install PKG

go get github.com/SimpaiX-net/licrypt

Current implementations
  • AES CTR

    In the form of hmac|iv|cipher, HMAC provides authenticity and integrity over iv + cipher as AES CTR is not solely secure

  • AES GCM - Endorsed: Highly efficient

    The GCM algorithm provides both data authenticity (integrity) and confidentiality therefore no HMAC is required

Benchmark
❯ go test -benchmem -run=^$ -bench ^BenchmarkAES128GCM$ github.com/SimpaiX-net/licrypt/tests -v
goos: windows
goarch: amd64
pkg: github.com/SimpaiX-net/licrypt/tests
cpu: AMD Ryzen 7 4800H with Radeon Graphics
BenchmarkAES128GCM
BenchmarkAES128GCM-16            2835874               430.9 ns/op           864 B/op          8 allocs/op
PASS
ok      github.com/SimpaiX-net/licrypt/tests    1.802s
Example
package tests

import (
	"log"

	aesgcm "github.com/SimpaiX-net/licrypt/aes-gcm"
)


func main() {
	crypt, err := (&aesgcm.Crypter{}).Init(
		SECRET,
	)

	if err != nil {
		log.Fatal(err)
	}

	encr, err := crypt.Encrypt([]byte("hallo wereld"))
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Encrypted: %s\n", encr)

	decr, err := crypt.Decrypt(encr)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Decrypted: %s", decr)
}
License

See LICENSE file

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypter

type Crypter interface {
	// Encrypt input and returns a hexstring
	Encrypt(input []byte) HexStr
	// Decrypts input and returns the decrypted input in plaintext
	Decrypt(input HexStr) (string, error)
}

type HexStr

type HexStr = []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL