base14

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: GPL-3.0 Imports: 5 Imported by: 35

README

go-base16384

base16384 interface of golang

Usage

Quick start

package main

import (
	"fmt"

	b14 "github.com/fumiama/go-base16384"
)

func main() {
	str := b14.EncodeString("1234567")
	fmt.Println(str, b14.DecodeString(str))
}

API

func Encode(b []byte) (encd []byte)

func EncodeLen(in int) (out int)

func EncodeTo(b, encd []byte) error

func EncodeToString(b []byte) string

func EncodeFromString(s string) []byte

func EncodeString(s string) string

func DecodeLen(in, offset int) (out int)

func Decode(b []byte) (decd []byte)

func DecodeTo(b []byte, decd []byte) error

func DecodeToString(d []byte) string

func DecodeFromString(s string) []byte

func DecodeString(s string) string

Stream API

package main

import (
	"bytes"
	"crypto/rand"
	"io"

	b14 "github.com/fumiama/go-base16384"
)

func main() {
	buf := make([]byte, 1024*1024+1)
	_, err := rand.Read(buf)
	if err != nil {
		panic(err)
	}
	w := bytes.NewBuffer(make([]byte, 0, 1024*1024+1))
	e := b14.NewEncoder(bytes.NewReader(buf))
	_, err = io.Copy(w, e)
	if err != nil {
		panic(err)
	}
	w2 := bytes.NewBuffer(make([]byte, 0, 1024*1024+1))
	d := b14.NewDecoder(bytes.NewReader(w.Bytes()))
	_, err = io.Copy(w2, d)
	if err != nil {
		panic(err)
	}
	if !bytes.Equal(buf, w2.Bytes()) {
		panic("fail!")
	}
}

Documentation

Overview

Package base14 base16384 的 go 接口

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString added in v1.3.0

func BytesToString(b []byte) string

BytesToString 没有内存开销的转换

func Decode

func Decode(b []byte) (decd []byte)

func DecodeFromString added in v1.5.0

func DecodeFromString(s string) []byte

func DecodeLen added in v1.4.0

func DecodeLen(in, offset int) (out int)

func DecodeString added in v1.2.0

func DecodeString(s string) string

func DecodeTo added in v1.4.0

func DecodeTo(b []byte, decd []byte) (int, error)

func DecodeToString added in v1.4.0

func DecodeToString(d []byte) string

func Encode

func Encode(b []byte) (encd []byte)

func EncodeFromString added in v1.4.0

func EncodeFromString(s string) []byte

func EncodeLen added in v1.4.0

func EncodeLen(in int) (out int)

func EncodeString added in v1.2.0

func EncodeString(s string) string

func EncodeTo added in v1.4.0

func EncodeTo(b, encd []byte) (int, error)

func EncodeToString added in v1.5.0

func EncodeToString(b []byte) string

func StringToBytes added in v1.3.0

func StringToBytes(s string) (b []byte)

StringToBytes 没有内存开销的转换

func UTF16BE2UTF8 added in v1.4.0

func UTF16BE2UTF8(b []byte) ([]byte, error)

UTF16BE2UTF8 to display the result as string

func UTF82UTF16BE added in v1.4.0

func UTF82UTF16BE(b []byte) ([]byte, error)

UTF82UTF16BE to decode from string

Types

type Decoder added in v1.4.0

type Decoder struct {
	io.Reader
	// contains filtered or unexported fields
}

func NewBufferedDecoder added in v1.4.0

func NewBufferedDecoder(b []byte) *Decoder

func NewDecoder added in v1.4.0

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Read added in v1.4.0

func (d *Decoder) Read(p []byte) (n int, err error)

type Encoder added in v1.4.0

type Encoder struct {
	io.Reader
	// contains filtered or unexported fields
}

func NewBufferedEncoder added in v1.4.0

func NewBufferedEncoder(b []byte) *Encoder

func NewEncoder added in v1.4.0

func NewEncoder(r io.Reader) *Encoder

func (*Encoder) Read added in v1.4.0

func (e *Encoder) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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