Categorygithub.com/itdesign-at/golib/crypt
modulepackage
1.0.0
Repository: https://github.com/itdesign-at/golib.git
Documentation: pkg.go.dev

# README

package crypt

FunctionComment
func NewBcrypt() Bcryptcreates an bcrypt handler
func (b *bcryptProperties) Encrypt(plainText string) (string, error)encrypt plaintext
func (b *bcryptProperties) HashedText(hashedText string)set a hashed text string
func (b *bcryptProperties) PlainText(plainText string)set a plain text string
func (b *bcryptProperties) Cost(cost int)sets bcrypt costs
func (b *bcryptProperties) Compare() boolchecks the hash against the plaintext
func GenerateEd25519KeyFiles(dir string, filename string) (string, error)generates ed25519 key files (id_ed25519 and id_ed25519.pub)
func NewEncryptedString(plainTextValue string) EncryptedStringcreates an Encrypted string
func NewDecryptedString(encryptedValue string) stringdecrypt an encrypted string
func (v EncryptedString) Value() stringreturns the decrypted plainTextValue
func (v EncryptedString) String() stringreturns the decrypted plainTextValue
func (v EncryptedString) MarshalText() ([]byte, error)
func (v *EncryptedString) UnmarshalText(text []byte) error
func (v EncryptedString) MarshalBinary() ([]byte, error)
func NewSymmetricEncryption() *SymCryptcreates an SymCrypt handler
func (s *SymCrypt) SetKey(key string) *SymCryptset an AES key
func (s *SymCrypt) SetPlainText(plainText string) *SymCryptset plain text to encrypt.
func (s *SymCrypt) GetCypherBase64() stringreturns the encrypted data stream as base64 encoded
func (s *SymCrypt) SetCypherBase64(base64String string) *SymCryptset cipher text as base64 string.
func (s *SymCrypt) GetPlainText() (string, error)returns the plaintext

# Functions

GenerateEd25519KeyFiles generates two files id_ed25519 and id_ed25519.pub in directory dir.
NewBcrypt is the main entry point.
NewDecryptedString decrypts an encrypted string.
NewEncryptedString creates a new EncryptedString by encrypting the supplied plainTextValue.
NewSymmetricEncryption is the entry point for AES encryption/decryption and can be used to encrypt a string and get the result as base64 string.

# Structs

EncryptedString is a sym crypt string.
SymCrypt is the main structure for symmetric encryption and holds plainText, key and cipher as unexported fields.

# Interfaces

Bcrypt is the main interface.