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 ¶
- func DecodeNum(a *big.Int, lenA int, b *big.Int, lenB int, c Codec) (string, error)
- func Num(s []uint16, radix uint64) (big.Int, error)
- func NumRev(s []uint16, radix uint64) (big.Int, error)
- func Str(x *big.Int, r []uint16, radix uint64) ([]uint16, error)
- func StrRev(x *big.Int, r []uint16, radix uint64) ([]uint16, error)
- type Codec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeNum ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.