Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
Decoder is an adapter allowing to use a function as a decoder.
ByteDecoder represents a byte decoder.
var Int64Decoder Decoder[int64] = func(b []byte) (int64, error) { return strconv.ParseInt(string(b), 10, 64) }
Int64Decoder represents an int64 decoder.
NilDecoder is a decoder that always returns a nil, no matter the input.
StringDecoder represents a string decoder.
func ByteEncryptedDecoder ¶
ByteEncryptedDecoder represents a byte encrypted decoder.
type Decrypter ¶
type Decrypter[T any] func([]byte, *rsa.PrivateKey) (T, error)
Decrypter is a function that decrypts a value.
var ByteDecrypter Decrypter[[]byte] = func(b []byte, key *rsa.PrivateKey) ([]byte, error) { hash := sha256.New() plainText, err := rsa.DecryptOAEP(hash, rand.Reader, key, b, nil) if err != nil { return nil, err } return plainText, nil }
ByteDecrypter represents a byte decrypter.
var StringDecrypter Decrypter[string] = func(value []byte, key *rsa.PrivateKey) (string, error) { hash := sha256.New() plainText, err := rsa.DecryptOAEP(hash, rand.Reader, key, value, nil) if err != nil { return "", err } return string(plainText), nil }
StringDecrypter represents a string decrypter.
type Encoder ¶
Encoder is an adapter allowing to use a function as an encoder.
ByteEncoder represents a byte encoder.
EncryptedEncoder represents an encrypted encoder.
var Int64Encoder Encoder[int64] = func(v int64) ([]byte, error) { return []byte(strconv.FormatInt(v, 10)), nil }
Int64Encoder represents an int64 encoder.
StringEncoder is a string encoder.
type Encrypter ¶
Encrypter is a function that encrypts a value.
var ByteEncrypter Encrypter[[]byte] = func(b []byte, key *rsa.PublicKey) ([]byte, error) { hash := sha256.New() ciperText, err := rsa.EncryptOAEP(hash, rand.Reader, key, b, nil) if err != nil { return nil, err } return ciperText, nil }
ByteEncrypter represents a byte encrypter.