encoding

package module
v0.0.0-...-1319df5 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 2

README

Mailchain - Encoding

Mailchain

Mailchain is a multi-chain communication protocol that helps you communicate with your users across any protocol. It provides end-to-end encryption by default, and supports 1:1, 1:many and group messaging.

Using Mailchain you can easily send messages to any blockchain address on different protocols.

Encoding

Mailchain supports messaging across multiple chains. Each blockchain protocol uses a predefined method for encoding data, including addresses. Mailchain needs to support encode and decode for all blockchain protocols. This repository contains Mailchain encoding functionality.

Find out more

We'd ❤ for you to join our growing community and get involved.

Follow @mailchain_xyz on Twitter to hear about new releases and updates.

Other channels to reach us can be found here: https://docs.mailchain.com/getting-help/.

License

Copyright 2022, Mailchain Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files 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.

Documentation

Index

Constants

View Source
const (
	// KindHex encoding value.
	KindHex = "hex/plain"
	// KindHex0XPrefix encoding value.
	KindHex0XPrefix = "hex/0x-prefix"
	// KindBase32 encoding value.
	KindBase32 = "base32/plain"
	// KindBase58 encoding value.
	KindBase58 = "base58/plain"
	// KindBase64 encoding value.
	KindBase64 = "base64/plain"
	// KindBase64URL encoding value.
	KindBase64URL = "base64/url"
	// KindBase58SubstrateAddress encoding value.
	KindBase58SubstrateAddress = "base58/ss58-address"
	// KindUTF8 encoding value.
	KindUTF8 = "text/utf-8"
)

Variables

This section is empty.

Functions

func DataPrefix

func DataPrefix() []byte

DataPrefix used to identify Mailchain messages.

func Decode

func Decode(encoding, src string) ([]byte, error)

Decode returns the bytes represented by the decoded string src.

Decode uses the decode method mapped to kind parameter. If the input is kind is unknown or the input is malformed for the decode method it returns an error.

func DecodeBase32

func DecodeBase32(src string) ([]byte, error)

DecodeBase32 returns the bytes represented by the base32 string src.

DecodeBase32 expects that src contains only base32 characters. If the input is malformed, DecodeBase32 returns an error.

func DecodeBase58

func DecodeBase58(src string) ([]byte, error)

DecodeBase58 returns the bytes represented by the base58 string src.

DecodeBase58 expects that src contains only base58 characters. If the input is malformed, DecodeBase58 returns an error.

func DecodeBase64

func DecodeBase64(src string) ([]byte, error)

DecodeBase64 returns the bytes represented by the base64 string src.

DecodeBase64 expects that src contains only base64 characters. If the input is malformed, DecodeBase64 returns an error.

func DecodeBase64URL

func DecodeBase64URL(src string) ([]byte, error)

DecodeBase64URL returns the bytes represented by the base64 string src. This method decodes without padding.

func DecodeHex

func DecodeHex(s string) ([]byte, error)

DecodeHex returns the bytes represented by the hexadecimal string s.

DecodeHex expects that src contains only hexadecimal characters and that src has even length. If the input is malformed, DecodeString returns the bytes decoded before the error.

func DecodeHexZeroX

func DecodeHexZeroX(in string) ([]byte, error)

DecodeHexZeroX returns the bytes represented by the hexadecimal string src.

DecodeHexZeroX expects that src contains only hex characters and must contain a `0x` prefix. If the input is malformed, DecodeHexZeroX returns an error.

func DecodeUTF8

func DecodeUTF8(src string) []byte

func Encode

func Encode(encoding string, src []byte) (string, error)

Encode returns the bytes encoded as requested by the encoding parameter.

func EncodeBase32

func EncodeBase32(src []byte) string

EncodeBase32 returns the string represented by the base32 byte src.

EncodeBase32 expects that src contains only base32 byte. If the input is malformed, EncodeBase32 returns an error.

func EncodeBase58

func EncodeBase58(src []byte) string

EncodeBase58 returns the string represented by the base58 byte src.

EncodeBase58 expects that src contains only base58 byte. If the input is malformed, EncodeBase58 returns an error.

func EncodeBase64

func EncodeBase64(src []byte) string

EncodeBase64 returns the string represented by the base64 byte src.

EncodeBase64 expects that src contains only base64 byte. If the input is malformed, EncodeBase64 returns an error.

func EncodeBase64URL

func EncodeBase64URL(src []byte) string

EncodeBase64URL returns the string represented by the base64 byte src. This method encodes without padding.

func EncodeHex

func EncodeHex(src []byte) string

EncodeHex returns the hexadecimal encoding of src.

func EncodeHexZeroX

func EncodeHexZeroX(src []byte) (encoded string)

EncodeHexZeroX encodes src into "0x"+hex.Encode. As a convenience, it returns the encoding type used, but this value is always TypeHex0XPrefix. EncodeHexZeroX uses hexadecimal encoding prefixed with "0x".

func EncodeUTF8

func EncodeUTF8(src []byte) string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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