1 Star 0 Fork 48

uller / dongle

forked from golang-module / dongle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
encode.go 994 Bytes
一键复制 编辑 原始数据 按行查看 历史
package dongle
const (
// BASE32 base32 encoding mode
BASE32 = "base32"
// BASE58 base58 encoding mode
BASE58 = "base58"
// BASE64 base64 encoding mode
BASE64 = "base64"
// HEX hex encoding mode
HEX = "hex"
)
// encode defines a encode struct.
type encode struct {
dongle
}
// newEncode returns a new encode instance.
func newEncode() encode {
return encode{}
}
// FromString encrypts from string.
func (e encode) FromString(s string) encode {
if s == emptyString {
return e
}
e.input = string2bytes(s)
return e
}
// FromBytes encrypts from byte slice.
func (e encode) FromBytes(b []byte) encode {
if len(b) > 0 {
e.input = b
}
return e
}
// ToString outputs as string.
func (e encode) ToString() string {
output := e.output
if output == nil {
output = e.input
}
return bytes2string(output)
}
// ToBytes outputs as byte slice.
func (e encode) ToBytes() []byte {
input, output := e.input, e.output
if len(input) == 0 {
return emptyBytes
}
return output
}
Go
1
https://gitee.com/Uller/dongle.git
git@gitee.com:Uller/dongle.git
Uller
dongle
dongle
master

搜索帮助