rs

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 3 Imported by: 6

README

Reed-Solomon ECC in Go

Implements error correcting codes using Russ Cox's gf256 library.

It doesn't implement interleaved data, the data is assumed to be external to the content.

GoDoc Build Status Coverage Status

Documentation

Overview

Package rs implements Reed-Solomon error correcting codes.

The code was inspired by ZXing's Java implementation but was reduced to only support 256 values space. Source: http://code.google.com/p/zxing/

Much credit is due to Sean Owen, William Rucklidge since portions of this code are an indirect port of their Java or C++ Reed-Solomon implementations.

Parts of ZXing's implementation have been replaced by Russ Cox's gf256 library. Source: http://code.google.com/p/rsc/source/browse/#hg%2Fgf256

Index

Constants

This section is empty.

Variables

View Source
var QRCodeField256 = NewField(0x11D, 2)

The Galois Field for QR codes. See http://research.swtch.com/field for more information.

x^8 + x^4 + x^3 + x^2 + 1

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	// Decodes given set of received codewords, which include both data and
	// error-correction codewords. Really, this means it uses Reed-Solomon to
	// detect and correct errors, in-place, in the input.
	//
	// Returns the number of errors corrected or an error if decoding failed.
	Decode(data, ecc []byte) (int, error)
}

Decoder can error correct data with the corresponding ECC codes.

func NewDecoder

func NewDecoder(f *Field) Decoder

NewDecoder creates a decoder in the defined field.

type Encoder

type Encoder interface {
	// Encode calculates the ECC code for data and writes it into ecc.
	Encode(data []byte, ecc []byte)
}

Encoder can encode data into ecc codes.

func NewEncoder

func NewEncoder(f *Field, c int) Encoder

NewEncoder generates a Reed-Solomon encoder that can generate ECC codes.

type Field

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

Field is a wrapper to gf256.Field so the type doesn't leak in.

func NewField

func NewField(poly int, α byte) *Field

NewField wraps gf256.NewField(). It is safe to use the premade QRCodeField256 all the time.

Notes

Bugs

  • It's far from complete. It can't accept total buffer size of more than 255 bytes. So len(data)+len(ecc) must be under 256 bytes.

Directories

Path Synopsis
internal
gf256
Package gf256 implements arithmetic over the Galois Field GF(256).
Package gf256 implements arithmetic over the Galois Field GF(256).

Jump to

Keyboard shortcuts

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