parse

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package parse builds parse trees for crypt(3) hashes.

Supported schemes:

  • DES: <value>(<value>)*
  • DES Extended (BSDi): _<value>(<value>)*
  • MCF/PHC: $<id>$fragment($<fragment>)* Where:
  • <fragment> is (<group>|<param>=<value>|<value>)
  • <group> is <param>=<value>,<param>=<value>(,<param>=<value>)*

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FragmentNode

type FragmentNode interface {
	Node
	// contains filtered or unexported methods
}

FragmentNode represents a fragment separated by '$'.

type GroupNode

type GroupNode struct {
	Values []*ValueNode // len(Values) > 0
}

GroupNode represents a comma-separated list of values.

func (*GroupNode) End

func (g *GroupNode) End() Pos

func (*GroupNode) Pos

func (g *GroupNode) Pos() Pos

func (*GroupNode) String

func (g *GroupNode) String() string

func (*GroupNode) Type

func (g *GroupNode) Type() NodeType

type Node

type Node interface {
	Type() NodeType
	String() string
	Pos() Pos // position of first byte belonging to the node
	End() Pos // position of first byte immediately after the node
	// contains filtered or unexported methods
}

Node is an element in the parse tree. The interface contains an unexported method so that only types local to this package can satisfy it.

type NodeType

type NodeType int

NodeType identifies the type of a parse tree node.

const (
	NodePrefix NodeType = iota
	NodeGroup
	NodeValue
)

func (NodeType) String

func (t NodeType) String() string

type Pos

type Pos int

Pos represents a byte position in the original input text.

type PrefixNode

type PrefixNode struct {
	Text string
	// contains filtered or unexported fields
}

PrefixNode holds a hash prefix, like '_', '$id$' or '$id,'.

func (*PrefixNode) End

func (p *PrefixNode) End() Pos

func (*PrefixNode) Pos

func (p *PrefixNode) Pos() Pos

func (*PrefixNode) String

func (p *PrefixNode) String() string

func (*PrefixNode) Type

func (p *PrefixNode) Type() NodeType

type SyntaxError

type SyntaxError struct {
	Offset int    // byte offset in input where error was detected
	Msg    string // description of error
}

SyntaxError suggests that the hash is invalid.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

type Tree

type Tree struct {
	Prefix    *PrefixNode
	Fragments []FragmentNode
}

Tree is the representation of a single parsed hash.

func Parse

func Parse(hash string) (*Tree, error)

Parse parses the hash string and returns the corresponding syntax tree.

type ValueNode

type ValueNode struct {
	Value string
	// contains filtered or unexported fields
}

ValueNode holds a single value.

func (*ValueNode) End

func (v *ValueNode) End() Pos

func (*ValueNode) Pos

func (v *ValueNode) Pos() Pos

func (*ValueNode) String

func (v *ValueNode) String() string

func (*ValueNode) Type

func (v *ValueNode) Type() NodeType

Jump to

Keyboard shortcuts

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