Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fumiama/go-base16384
base16384 interface of golang
https://github.com/fumiama/go-base16384
Last synced: 2 months ago
JSON representation
base16384 interface of golang
- Host: GitHub
- URL: https://github.com/fumiama/go-base16384
- Owner: fumiama
- License: gpl-3.0
- Created: 2021-08-07T16:28:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-19T07:33:51.000Z (over 1 year ago)
- Last Synced: 2024-06-18T21:44:09.315Z (7 months ago)
- Language: Go
- Size: 64.5 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-base16384
base16384 interface of golang# Usage
## Quick start```go
package mainimport (
"fmt"b14 "github.com/fumiama/go-base16384"
)func main() {
str := b14.EncodeString("1234567")
fmt.Println(str, b14.DecodeString(str))
}
```## API
```go
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
```go
package mainimport (
"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!")
}
}
```