Documentation
¶
Overview ¶
base91 is a Go adaptation for the en-/decoding library to encoding binary data as ASCII. It is based on the C version from basE91 (http://base91.sourceforge.net/).
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var LineBreakAfter uint = 76
Functions ¶
func Decode ¶
Decode takes base91 data and returns it in decoded form. Please use the faster NewDecoder(src io.Reader) io.Reader implementation if possible.
Example ¶
package main
import (
"fmt"
"catinello.eu/base91"
)
func main() {
in := []byte("fGn/1+~j/nFa!YAS77Z.wnXBD")
out := base91.Decode(in)
fmt.Println(string(out))
}
Output: ABC_def→1234567890
func Encode ¶
Encode takes data and returns it in base91 encoded form. Please use the faster NewEncoder(dst io.Writer) io.WriteCloser implementation if possible.
Example ¶
package main
import (
"fmt"
"catinello.eu/base91"
)
func main() {
in := []byte("ABC_def→1234567890")
out := base91.Encode(in)
fmt.Println(string(out))
}
Output: fGn/1+~j/nFa!YAS77Z.wnXBD
func NewDecoder ¶
NewDecoder takes an io.Reader as source to read encoded data from.
Example ¶
package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"catinello.eu/base91"
)
func main() {
sample := []byte("fGn/1+~j/nFa!YAS77Z.wnXBD")
r := bytes.NewReader(sample)
d := base91.NewDecoder(r)
var w []byte
_, err := d.Read(w)
if err != nil {
log.Fatalf("Error decoding `%s`", sample)
}
buf, err := ioutil.ReadAll(d)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(buf))
}
Output: ABC_def→1234567890
func NewEncoder ¶
func NewEncoder(dst io.Writer) io.WriteCloser
NewEncoder takes an io.Writer as destination to write encoded data to.
Example ¶
package main
import (
"bytes"
"fmt"
"log"
"catinello.eu/base91"
)
func main() {
var sample []byte = []byte("ABC_def→1234567890")
w := &bytes.Buffer{}
e := base91.NewEncoder(w)
_, err := e.Write(sample)
if err != nil {
log.Fatalf("Error encoding `%s`", sample)
}
err = e.Close()
if err != nil {
log.Fatalf("Error encoding `%s`", sample)
}
fmt.Println(w.String())
}
Output: fGn/1+~j/nFa!YAS77Z.wnXBD
func NewEncoderWrapped ¶
func NewEncoderWrapped(dst io.Writer) io.WriteCloser
NewEncoderWrapped takes an io.Writer as destination to write encoded data to and wraps the line after LineBreakAfter (defaults to 76).
Types ¶
This section is empty.