utils

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptData

func DecryptData(secretKeyOrPwd string, ctStr string) ([]byte, error)

func DecryptStream

func DecryptStream(secretKeyOrPwd string, dst io.Writer, src io.Reader) error

func EncryptData

func EncryptData(keyOrPwd string, data []byte, compress bool) (ctStr string, ctUrl string, err error)

func EncryptStream

func EncryptStream(keyOrPwd string, dst io.Writer, src io.Reader, compress, encode bool) error

func GetPublicKey

func GetPublicKey(secretKeyOrPwd string, quantumSafe bool) (pubKeyStr, pubKeyUrl string, err error)

func GetSanitisedKeyOrPwd

func GetSanitisedKeyOrPwd(keyPwdStr string) (sanitisedKey string, isKey bool)

func NewDecryptingReader

func NewDecryptingReader(secretKeyOrPwd string, src io.Reader) (io.Reader, error)

func NewEncryptingWriter

func NewEncryptingWriter(keyOrPwd string, dst io.Writer, compress, encode bool) (encryptingWriteCloser io.WriteCloser, err error)

Types

type ThresholdFileWriter added in v1.20.0

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

ThresholdFileWriter buffers writes until a threshold length is reached, then creates the output file, flushes the buffer, and passes all subsequent writes through.

func NewThresholdFileWriter added in v1.20.0

func NewThresholdFileWriter(filePath string, threshold int) *ThresholdFileWriter

func (*ThresholdFileWriter) Close added in v1.20.0

func (tw *ThresholdFileWriter) Close() error

Close flushes remaining data and closes the file.

func (*ThresholdFileWriter) Discard added in v1.20.0

func (tw *ThresholdFileWriter) Discard() error

Discard drops the buffer without writing and removes the file if it was already created.

func (*ThresholdFileWriter) Flush added in v1.20.0

func (tw *ThresholdFileWriter) Flush() error

Flush writes any remaining buffered data, creating the file if needed, and syncs it.

func (*ThresholdFileWriter) Write added in v1.20.0

func (tw *ThresholdFileWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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