parse

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

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

Parser class for pasing packet

func New

func New(cxt *context.Context, reader io.Reader) (*Parser, error)

New returns Parser instance

func NewBytes

func NewBytes(cxt *context.Context, data []byte) (*Parser, error)

NewBytes returns Parser instance

func (*Parser) Parse

func (p *Parser) Parse() (*result.Info, error)

Parse returns packet result.

Example
package main

import (
	"fmt"

	"github.com/goark/gpgpdump/parse"
	"github.com/goark/gpgpdump/parse/context"
)

const (
	openpgpStr = `
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iF4EARMIAAYFAlTDCN8ACgkQMfv9qV+7+hg2HwEA6h2iFFuCBv3VrsSf2BREQaT1
T1ZprZqwRPOjiLJg9AwA/ArTwCPz7c2vmxlv7sRlRLUI6CdsOqhuO1KfYXrq7idI
=ZOTN
-----END PGP SIGNATURE-----
`
)

var (
	openpgpData = []byte(openpgpStr)
	cxt         = context.New()
)

func main() {
	p, err := parse.NewBytes(cxt, openpgpData)
	if err != nil {
		return
	}
	info, err := p.Parse()
	if err != nil {
		return
	}
	if info != nil && len(info.Packets) > 0 {
		fmt.Println(info.Packets[0].Name)
	}
}

/* Copyright 2017-2020 Spiegel
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Output:

Signature Packet (tag 2)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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