elog

package module
v0.0.0-...-b61c1b1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

README

elog

A logging library in Go w/ encryption. This library takes inspiration from this StackOverflow thread.

(But really,) WTF is this?

This logger library uses an idea from the StackOverflow thread above that an encrypted log should encrypt itself based off every entry. In this library, we use AES encryption (with the previous hash of the entry as the encryption key) to accomplish this. We also use a random seed that is generated by a function every log entry, and use this to generate the nonce. The nonce is then removed from the log output because when decrypting, we would be able to use the seed function to predict the nonce and get a nice decrypted log :>

Why?

I need something to do while waiting an hour and thirty minutes for my next class to start. I should've chose a better schedule for my first semester!

Features?

None, because I suck. In the future we might have

  • Some more cool formatting stuff (because formatting is cool)
  • ??? (feel free to make an issue for feature requests)

Benchmark

benchmark_image

Documentation

Index

Constants

View Source
const (
	MAX_PREFERED_EXTRA_DATA_SIZE int = 2048
	MAX_PREFERED_LOG_SIZE        int = (1 << 16) - 1 - MAX_PREFERED_EXTRA_DATA_SIZE
)
View Source
const (
	LoggerModeTypeInfo uint64 = 1 << iota
	LoggerModeTypeWarning
	LoggerModeTypeError
	LoggerModeTypeFatal
	LoggerModeTypeDebug
)
View Source
const (
	LoggerOptIncludeTime uint64 = 1 << iota
)

Variables

Functions

func Decrypt

func Decrypt(encrypted, decrypted *os.File, opts SeedOpts) error

func HasType

func HasType(types, t uint64) bool

func RegisterMode

func RegisterMode(t uint64, v string) bool

RegisterMode registers a logger type into the types map.

func WithFlags

func WithFlags(types ...uint64) uint64

WithFlags returns a final type flag with all the types that the logger should use.

Types

type Logger

type Logger struct {
	sync.Mutex

	CleanOut io.Writer
	Out      io.WriteCloser

	Modes uint64
	Opts  uint64
	// contains filtered or unexported fields
}

func New

func New(f io.WriteCloser, modes, opts, seed uint64, sf SeedFunc) *Logger

func (*Logger) Log

func (l *Logger) Log(log_mode uint64) *entry

type SeedFunc

type SeedFunc func(seed uint64) uint64

type SeedOpts

type SeedOpts struct {
	Seed uint64
	F    SeedFunc
}

Jump to

Keyboard shortcuts

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