Documentation ¶
Overview ¶
Package rc4 implements RC4 encryption, as defined in Bruce Schneier's Applied Cryptography.
RC4 is cryptographically broken and should not be used for secure applications.
Package suffixarray implements substring search in logarithmic time using an in-memory suffix array.
Example use:
// create index for some data index := suffixarray.New(data) // lookup byte slice s offsets1 := index.Lookup(s, -1) // the list of all indices where s occurs in data offsets2 := index.Lookup(s, 3) // the list of at most 3 indices where s occurs in data
Index ¶
Constants ¶
const ALLOCATION_SIZE = MAX_LENGTH
const BigEndian = false
const CALCULATE_DISTRIBUTION = false
const COUNTING_SORT_BITS uint64 = 10
const COUNTING_SORT_SIZE uint64 = 1 << COUNTING_SORT_BITS
const LittleEndian = true
const MAX_LENGTH uint32 = (256 * 384) - 1 // this is the maximum
const REFERENCE_MODE = true
Variables ¶
var Pool = sync.Pool{New: func() interface{} { var d ScratchData d.hasher = sha256.New() d.stage1_result = ((*[MAX_LENGTH + 1]uint16)(unsafe.Pointer(&d.indices[0]))) d.stage1_result_bytes = ((*[(MAX_LENGTH) * 2]byte)(unsafe.Pointer(&d.indices[0]))) d.sa_bytes = ((*[(MAX_LENGTH) * 4]byte)(unsafe.Pointer(&d.sa[0]))) return &d }}
Functions ¶
func BigEndian_Uint64 ¶
func ReadBigUint32Unsafe ¶
this is NOT much faster and efficient, however it won't work on appengine since it doesn't have the unsafe package. Also this would blow up silently if len(b) < 4.
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
A Cipher is an instance of RC4 using a particular key.
func NewCipher ¶
NewCipher creates and returns a new Cipher. The key argument should be the RC4 key, at least 1 byte and at most 256 bytes.
func (*Cipher) XORKeyStream ¶
XORKeyStream sets dst to the result of XORing src with the key stream. Dst and src must overlap entirely or not at all.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index implements a suffix array for fast substring search.
func (*Index) Bytes ¶
Bytes returns the data over which the index was created. It must not be modified.
func (*Index) FindAllIndex ¶
FindAllIndex returns a sorted list of non-overlapping matches of the regular expression r, where a match is a pair of indices specifying the matched slice of x.Bytes(). If n < 0, all matches are returned in successive order. Otherwise, at most n matches are returned and they may not be successive. The result is nil if there are no matches, or if n == 0.
func (*Index) Lookup ¶
Lookup returns an unsorted list of at most n indices where the byte string s occurs in the indexed data. If n < 0, all occurrences are returned. The result is nil if s is empty, s is not found, or n == 0. Lookup time is O(log(N)*len(s) + len(result)) where N is the size of the indexed data.
type KeySizeError ¶
type KeySizeError int
func (KeySizeError) Error ¶
func (k KeySizeError) Error() string
type ScratchData ¶
type ScratchData struct {
// contains filtered or unexported fields
}