package gf256
import "rsc.io/qr/gf256"
Package gf256 implements arithmetic over the Galois Field GF(256).
Index ¶
- type Field
- func NewField(poly, α int) *Field
- func (f *Field) Add(x, y byte) byte
- func (f *Field) Exp(e int) byte
- func (f *Field) Inv(x byte) byte
- func (f *Field) Log(x byte) int
- func (f *Field) Mul(x, y byte) byte
- type RSEncoder
Types ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
A Field represents an instance of GF(256) defined by a specific polynomial.
func NewField ¶
NewField returns a new field corresponding to the polynomial poly and generator α. The Reed-Solomon encoding in QR codes uses polynomial 0x11d with generator 2.
The choice of generator α only affects the Exp and Log operations.
func (*Field) Add ¶
Add returns the sum of x and y in the field.
func (*Field) Exp ¶
Exp returns the base-α exponential of e in the field. If e < 0, Exp returns 0.
func (*Field) Inv ¶
Inv returns the multiplicative inverse of x in the field. If x == 0, Inv returns 0.
func (*Field) Log ¶
Log returns the base-α logarithm of x in the field. If x == 0, Log returns -1.
func (*Field) Mul ¶
Mul returns the product of x and y in the field.
type RSEncoder ¶
type RSEncoder struct {
// contains filtered or unexported fields
}
An RSEncoder implements Reed-Solomon encoding over a given field using a given number of error correction bytes.
func NewRSEncoder ¶
NewRSEncoder returns a new Reed-Solomon encoder over the given field and number of error correction bytes.
func (*RSEncoder) ECC ¶
ECC writes to check the error correcting code bytes for data using the given Reed-Solomon parameters.
Source Files ¶
gf256.go
- Version
- v0.1.0
- Published
- Nov 21, 2016
- Platform
- js/wasm
- Imports
- 1 packages
- Last checked
- 2 hours ago –
Tools for package owners.