fpeUtils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fpeUtils provides some encoding helpers for use in the FF1 and FF3 format-preserving encryption packages.

Package fpeUtils provides some encoding helpers for use in the FF1 and FF3 format-preserving encryption packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeNum

func DecodeNum(a *big.Int, lenA int, b *big.Int, lenB int, c Codec) (string, error)

DecodeNum constructs a string from indices into the alphabet embedded in the Codec. The indices are encoded in the big Ints a and b. lenA and lenB are the number of characters that should be built from the corresponding big Ints.

func Num

func Num(s []uint16, radix uint64) (big.Int, error)

Num constructs a big.Int from an array of uint16, where each element represents one digit in the given radix. The array is arranged with the most significant digit in element 0, down to the least significant digit in element len-1.

func NumRev

func NumRev(s []uint16, radix uint64) (big.Int, error)

NumRev constructs a big.Int from an array of uint16, where each element represents one digit in the given radix. The array is arranged with the least significant digit in element 0, down to the most significant digit in element len-1.

func Str

func Str(x *big.Int, r []uint16, radix uint64) ([]uint16, error)

Str populates an array of uint16 with digits representing big.Int x in the specified radix. The array is arranged with the most significant digit in element 0. The array is built from big.Int x from the least significant digit upwards. If the supplied array is too short, the most significant digits of x are quietly lost.

func StrRev

func StrRev(x *big.Int, r []uint16, radix uint64) ([]uint16, error)

StrRev populates an array of uint16 with digits representing big.Int x in the specified radix. The array is arranged with the least significant digit in element 0. The array is built from big.Int x from the least significant digit upwards. If the supplied array is too short, the most significant digits of x are quietly lost.

Types

type Codec

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

Codec supports the conversion of an arbitrary alphabet into ordinal values from 0 to length of alphabet-1. Element 'rtu' (rune-to-uint16) supports the mapping from runes to ordinal values. Element 'utr' (uint16-to-rune) supports the mapping from ordinal values to runes.

func NewCodec

func NewCodec(s string) (Codec, error)

NewCodec builds a Codec from the set of unique characters taken from the string s. The string contains arbitrary Utf-8 characters. It is an error to try to construct a codec from an alphabet with more the 65536 characters.

func (*Codec) Decode

func (a *Codec) Decode(n []uint16) (string, error)

Decode constructs a string from an array of ordinal values where each value specifies the position of the character in the alphabet. It is an error for the array to contain values outside the boundary of the alphabet.

func (*Codec) Encode

func (a *Codec) Encode(s string) ([]uint16, error)

Encode the supplied string as an array of ordinal values giving the position of each character in the alphabet. It is an error for the supplied string to contain characters than are not in the alphabet.

func (*Codec) Radix

func (a *Codec) Radix() int

Radix returns the size of the alphabet supported by the Codec.

Jump to

Keyboard shortcuts

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