crypt

package
v1.9.9 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Default crypters: - AES GCM HMAC - AES CTR HMAC

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AES_CTR

type AES_CTR struct {
	// contains filtered or unexported fields
}

Default crypter type; uses AES CTR HMAC

func New_AES_CTR

func New_AES_CTR(block cipher.Block, hmac hash.Hash) *AES_CTR

Creates a new AES CTR HMAC object

func (*AES_CTR) Decrypt

func (c *AES_CTR) Decrypt(data string) (string, error)

Decrypts data and returns the plaintext string of the encrypted data or error. The returned errors can be related to authentication or some sort of other failure

func (*AES_CTR) Encrypt

func (c *AES_CTR) Encrypt(data string) (string, error)

Encrypts data and returns the base64 encoded string of the encrypted data or error on failure

type AES_GCM

type AES_GCM struct {
	// contains filtered or unexported fields
}

Default crypter type; uses AES GCM HMAC

func New_AES_GCM

func New_AES_GCM(block cipher.Block, hmac hash.Hash) *AES_GCM

Creates a new AES GCM HMAC object

func (*AES_GCM) Decrypt

func (c *AES_GCM) Decrypt(data string) (string, error)

Decrypts data and returns the plaintext string of the encrypted data or error. The returned errors can be related to authentication or some sort of other failure

func (*AES_GCM) Encrypt

func (c *AES_GCM) Encrypt(data string) (string, error)

Encrypts data and returns the base64 encoded string of the encrypted data or error on failure

type CrypterI

type CrypterI interface {
	/*
		Should encrypt given data and return it in base64 format
	*/
	Encrypt(data string) (string, error)
	/*
		Should Decrypt given data and return its plaintext.
		'data' here is the  base64 encoded string, when the data is decoded it represents
		the encryption cipher text in bytes
	*/
	Decrypt(data string) (string, error)
}

# CrypterI object Exposes the special methods a crypter has to introduce to satisfy the crypter interface.

For examples please consider looking at the simpa/engine/crypt examples. Like:

  • AES_GCM HMAC
  • AES_CTR HMAC

This crypter is used for securecookie's and sessions.

The crypter object should be set using: [Engine SecureCookie]: https://pkg.go.dev/github.com/SimpaiX-net/simpa/engine#Engines

Source Files

  • crypter.go

Jump to

Keyboard shortcuts

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