obfuscator

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 9 Imported by: 0

README

Welcome to IQooLogic/obfuscator

Introduction

The obfuscator package enables Go programs to encode and decode sensitive values such as passwords to store them in config files.

Installation and usage

The import path for the package is github.com/IQooLogic/obfuscator.

To install it, run:

go get github.com/IQooLogic/obfuscator

License

The obfuscator package is licensed under the MIT license. Please see the LICENSE file for details.

See LICENSE

Example

package main

import (
	"fmt"
	"github.com/IQooLogic/obfuscator"
)

func main() {
	originalText := "simple text or password"
	o := obfuscator.New([]byte("randompassphrase"))
	// obfuscate
	obfuscatedText, err := o.Obfuscate(originalText)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	}
	fmt.Printf("Obfuscated text: %s\n", obfuscatedText)

	// unobfuscate
	unobfuscatedText, err := o.Unobfuscate(obfuscatedText)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	}
	fmt.Printf("Unobfuscated text: %s\n", unobfuscatedText)
}

See Examples

Documentation

Index

Constants

View Source
const DefaultSeparator = "$"
View Source
const SaltLength = 8
View Source
const Version = "o1"

Variables

View Source
var ErrorInvalidObfuscatedString = errors.New("invalid obfuscated string")
View Source
var ErrorUnsupportedVersion = errors.New("unsupported obfuscator version")

Functions

This section is empty.

Types

type Config

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

type Obfuscator

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

func New

func New(passphrase []byte, options ...Option) Obfuscator

func (Obfuscator) Obfuscate

func (o Obfuscator) Obfuscate(text string) (string, error)

func (Obfuscator) Unobfuscate

func (o Obfuscator) Unobfuscate(obfusctatedText string) (string, error)

type Option

type Option func(*Config)

func WithSaltLength

func WithSaltLength(length uint8) Option

func WithSeparator

func WithSeparator(separator string) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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