scramble

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: MIT Imports: 5 Imported by: 0

README

scramble

GoDoc

scramble is a golang package that scramble integer numbers.

Installation

go get github.com/kechako/scramble

Usage

package main

import (
	"fmt"

	"github.com/kechako/scramble"
)

func main() {
	// scramble salt is randomly generated
	// use NewScrambler32WithSalt if you want to specify a salt
	s := scramble.NewScrambler32()

	scrambled := s.Scramble(1234)
	fmt.Println(scrambled)
	// 4085920800

	unscrambled := s.Scramble(scrambled)
	fmt.Println(unscrambled)
	// 1234
}

Documentation

Overview

Package scramble is a package that scramble integer numbers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenRandomSalt16

func GenRandomSalt16() (uint16, uint16)

GenRandomSalt16 randomly generates a salt and its inverse used by scrambler. The salt is a 16 bits unsigned integer.

func GenRandomSalt32

func GenRandomSalt32() (uint32, uint32)

GenRandomSalt32 randomly generates a salt and its inverse used by scrambler. The salt is a 32 bits unsigned integer.

func GenRandomSalt64

func GenRandomSalt64() (uint64, uint64)

GenRandomSalt64 randomly generates a salt and its inverse used by scrambler. The salt is a 64 bits unsigned integer.

func GenRandomSalt8

func GenRandomSalt8() (uint8, uint8)

GenRandomSalt8 randomly generates a salt and its inverse used by scrambler. The salt and the inverse is a 8 bits unsigned integer.

func GenSaltInverse16

func GenSaltInverse16(salt uint16) uint16

GenSaltInverse16 returns a inverse of the salt. The salt and the inverse is a 16 bits unsigned integer.

func GenSaltInverse32

func GenSaltInverse32(salt uint32) uint32

GenSaltInverse32 returns a inverse of the salt. The salt and the inverse is a 32 bits unsigned integer.

func GenSaltInverse64

func GenSaltInverse64(salt uint64) uint64

GenSaltInverse64 returns a inverse of the salt. The salt and the inverse is a 64 bits unsigned integer.

func GenSaltInverse8

func GenSaltInverse8(salt uint8) uint8

GenSaltInverse8 returns a inverse of the salt. The salt and the inverse is a 8 bits unsigned integer.

Types

type Scrambler16

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

Scrambler16 scrambles 16 bit unsigned integers.

func NewScrambler16

func NewScrambler16() *Scrambler16

NewScrambler16 returns a new *Scramble16 with random salt and its inverse.

func NewScrambler16WithSalt

func NewScrambler16WithSalt(salt uint16) *Scrambler16

NewScrambler16WithSalt returns a new *Scramble16 with the salt and its inverse.

func (*Scrambler16) Scramble

func (s *Scrambler16) Scramble(v uint16) uint16

Scramble scrambles v.

type Scrambler32

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

Scrambler32 scrambles 32 bit unsigned integers.

func NewScrambler32

func NewScrambler32() *Scrambler32

NewScrambler32 returns a new *Scramble32 with random salt and its inverse.

func NewScrambler32WithSalt

func NewScrambler32WithSalt(salt uint32) *Scrambler32

NewScrambler32WithSalt returns a new *Scramble32 with the salt and its inverse.

func (*Scrambler32) Scramble

func (s *Scrambler32) Scramble(v uint32) uint32

Scramble scrambles v.

type Scrambler64

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

Scrambler64 scrambles 64 bit unsigned integers.

func NewScrambler64

func NewScrambler64() *Scrambler64

NewScrambler64 returns a new *Scramble64 with random salt and its inverse.

func NewScrambler64WithSalt

func NewScrambler64WithSalt(salt uint64) *Scrambler64

NewScrambler64WithSalt returns a new *Scramble64 with the salt and its inverse.

func (*Scrambler64) Scramble

func (s *Scrambler64) Scramble(v uint64) uint64

Scramble scrambles v.

type Scrambler8

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

Scrambler8 scrambles 8 bit unsigned integers.

func NewScrambler8

func NewScrambler8() *Scrambler8

NewScrambler8 returns a new *Scramble8 with random salt and its inverse.

func NewScrambler8WithSalt

func NewScrambler8WithSalt(salt uint8) *Scrambler8

NewScrambler8WithSalt returns a new *Scramble8 with the salt and its inverse.

func (*Scrambler8) Scramble

func (s *Scrambler8) Scramble(v uint8) uint8

Scramble scrambles v.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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