Documentation
¶
Overview ¶
Package base64simd implements base64 encoding (as specified in RFC 4648) using SIMD instructions (currently experimental, enabled with GOEXPERIMENT=simd environment variable).
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var RawStdEncoding = StdEncoding.withoutPadding()
RawStdEncoding performs standard base64 encoding using the standard 64 character alphabet, but without padding, as defined in RFC 4648.
var RawUrlEncoding = UrlEncoding.withoutPadding()
RawUrlEncoding performs alternate base64url encoding using the URL (and filename) safe alternate 64 character alphabet, but without padding, as defined in RFC 4648.
var StdEncoding = newEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
StdEncoding performs standard base64 encoding using the standard 64 character alphabet as defined in RFC 4648.
var UrlEncoding = newEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_").urlSafe()
UrlEncoding performs alternate base64url encoding using the URL (and filename) safe alternate 64 character alphabet as defined in RFC 4648.
Functions ¶
This section is empty.
Types ¶
type Encoding ¶
type Encoding struct {
// contains filtered or unexported fields
}
func (*Encoding) Decode ¶
Decode decodes data from source using the encoding e, writing upto encoding/base64.Encoding.DecodedLen(len(source)) bytes to destination and returns the actual number of bytes written.
destination MUST have at least size encoding/base64.Encoding.DecodedLen(len(source)) else Decode will panic.
Example ¶
package main
import (
"encoding/base64"
"fmt"
"codeberg.org/jongray/base64simd"
)
func main() {
sourceBytes := []byte("Zm9vYmFy")
destinationBytes := make([]byte, base64.StdEncoding.DecodedLen(len(sourceBytes)))
n, _ := base64simd.StdEncoding.Decode(destinationBytes, sourceBytes)
fmt.Println(string(destinationBytes[:n]))
}
Output: foobar
func (*Encoding) Encode ¶
Encode encodes data from source using the encoding e, writing encoding/base64.Encoding.EncodedLen(len(source)) bytes to destination.
destination MUST have at least size encoding/base64.Encoding.EncodedLen(len(source)) else Encode will panic.
Example ¶
package main
import (
"encoding/base64"
"fmt"
"codeberg.org/jongray/base64simd"
)
func main() {
sourceBytes := []byte("foobar")
destinationBytes := make([]byte, base64.StdEncoding.EncodedLen(len(sourceBytes)))
base64simd.StdEncoding.Encode(destinationBytes, sourceBytes)
fmt.Println(string(destinationBytes))
}
Output: Zm9vYmFy