diycode

package
v0.0.0-...-43e49cb Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

README

diycode

import "gitee.com/minph/siphan/diycode"

Overview

Export List

Constants

const CodeStr = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.?!:;+-*/^@0123456789%<>#$&=_|()\"'{}[]~` + "` "

func Base2to10

func Base2to10[T Number](num T, base T) T

N 进制转十进制

func Decode

func Decode(text string, format []string) (string, error)

解码 使用默认字符项数组

func DecodeSlice

func DecodeSlice(text string, format []string, codeSlice CodeSlice) (string, error)

通过自定义字符项数组解码

func DecodeTextByUnicode

func DecodeTextByUnicode(text string) (string, error)

通过 Unicode 解码字符串

func Encode

func Encode(text string, format []string) (string, error)

编码 使用默认字符项数组

func EncodeSlice

func EncodeSlice(text string, format []string, codeSlice CodeSlice) (string, error)

通过自定义字符项数组编码

func EncodeTextByUnicode

func EncodeTextByUnicode(text string) string

通过 Unicode 编码字符串

func N10toBase

func N10toBase[T Number](num T, base T) []T

十进制转 N 进制

func Shuffle

func Shuffle[T any](arr []T) []T

打乱数组

func ShuffleStr

func ShuffleStr(str string) string

打乱字符串

type Code

type Code struct {
    Char  string
    Index int
}

单个字符项

type CodeSlice

type CodeSlice []Code

字符项数组

func GetCodeSlice
func GetCodeSlice() CodeSlice

生成默认字符项数组

func GetCodeSliceFromStr
func GetCodeSliceFromStr(str string) CodeSlice

从自定义字符串生成字符项数组

func GetRandCodeSlice
func GetRandCodeSlice() (CodeSlice, string)

生成随即乱序字符项数组

func (CodeSlice) FindChar
func (c CodeSlice) FindChar(char string) (*Code, error)

字符项数组查找指定字符 return nil if not found

func (CodeSlice) FindIndex
func (c CodeSlice) FindIndex(index int) (*Code, error)

字符项数组查找指定 index 位置 return nil if not found

func (CodeSlice) GenHexKey
func (c CodeSlice) GenHexKey() (*HexKey, error)

通过指定的有序的字符项数组

默认指定为 diycode.CodeStr

令乱序的字符项数组生成 16 进制字符串

func (CodeSlice) GenHexKeyFromOrderSlice
func (c CodeSlice) GenHexKeyFromOrderSlice(orderSlice *CodeSlice) (*HexKey, error)

通过指定的有序的字符项数组 令乱序的字符项数组生成 16 进制字符串

func (CodeSlice) GenInputHexData
func (c CodeSlice) GenInputHexData(text string) (*HexKey, error)

通过 CodeSlice 将指定 string 转为 Hex 码

func (CodeSlice) GenStr
func (c CodeSlice) GenStr() string
func (CodeSlice) ParseHexData
func (c CodeSlice) ParseHexData(h *HexKey) (string, error)
func (CodeSlice) ParseHexDataList
func (c CodeSlice) ParseHexDataList(list []string) (string, error)

type HexKey

type HexKey struct {
    List       []string
    OrderSlice CodeSlice
}

16 进制字符串

func (*HexKey) ParseOriginText
func (h *HexKey) ParseOriginText() (string, error)

反解原始字符串

func (*HexKey) ParseToCodeSlice
func (h *HexKey) ParseToCodeSlice() (CodeSlice, error)
func (*HexKey) PrintStringText
func (h *HexKey) PrintStringText() string

type Number

type Number interface {
    ~int | ~int64
}

Documentation

Index

Constants

View Source
const CodeStr = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.?!:;+-*/^@0123456789%<>#$&=_|()\"'{}[]~` + "` "

Variables

This section is empty.

Functions

func Base2to10

func Base2to10[T Number](num T, base T) T

N进制转十进制

func Decode

func Decode(text string, format []string) (string, error)

解码 使用默认字符项数组

func DecodeSlice

func DecodeSlice(text string, format []string, codeSlice CodeSlice) (string, error)

通过自定义字符项数组解码

func DecodeTextByUnicode

func DecodeTextByUnicode(text string) (string, error)

通过Unicode解码字符串

func Encode

func Encode(text string, format []string) (string, error)

编码 使用默认字符项数组

func EncodeSlice

func EncodeSlice(text string, format []string, codeSlice CodeSlice) (string, error)

通过自定义字符项数组编码

func EncodeTextByUnicode

func EncodeTextByUnicode(text string) string

通过Unicode编码字符串

func N10toBase

func N10toBase[T Number](num T, base T) []T

十进制转N进制

func Shuffle

func Shuffle[T any](arr []T) []T

打乱数组

func ShuffleStr

func ShuffleStr(str string) string

打乱字符串

Types

type Code

type Code struct {
	Char  string
	Index int
}

单个字符项

type CodeSlice

type CodeSlice []Code

字符项数组

func GetCodeSlice

func GetCodeSlice() CodeSlice

生成默认字符项数组

func GetCodeSliceFromStr

func GetCodeSliceFromStr(str string) CodeSlice

从自定义字符串生成字符项数组

func GetRandCodeSlice

func GetRandCodeSlice() (CodeSlice, string)

生成随即乱序字符项数组

func (CodeSlice) FindChar

func (c CodeSlice) FindChar(char string) (*Code, error)

字符项数组查找指定字符 return nil if not found

func (CodeSlice) FindIndex

func (c CodeSlice) FindIndex(index int) (*Code, error)

字符项数组查找指定index位置 return nil if not found

func (CodeSlice) GenHexKey

func (c CodeSlice) GenHexKey() (*HexKey, error)

通过指定的有序的字符项数组

默认指定为 diycode.CodeStr

令乱序的字符项数组生成16进制字符串

func (CodeSlice) GenHexKeyFromOrderSlice

func (c CodeSlice) GenHexKeyFromOrderSlice(orderSlice *CodeSlice) (*HexKey, error)

通过指定的有序的字符项数组 令乱序的字符项数组生成16进制字符串

func (CodeSlice) GenInputHexData

func (c CodeSlice) GenInputHexData(text string) (*HexKey, error)

通过 CodeSlice 将指定 string 转为 Hex 码

func (CodeSlice) GenStr

func (c CodeSlice) GenStr() string

func (CodeSlice) ParseHexData

func (c CodeSlice) ParseHexData(h *HexKey) (string, error)

func (CodeSlice) ParseHexDataList

func (c CodeSlice) ParseHexDataList(list []string) (string, error)

type HexKey

type HexKey struct {
	List       []string
	OrderSlice CodeSlice
}

16进制字符串

func (*HexKey) ParseOriginText

func (h *HexKey) ParseOriginText() (string, error)

反解原始字符串

func (*HexKey) ParseToCodeSlice

func (h *HexKey) ParseToCodeSlice() (CodeSlice, error)

func (*HexKey) PrintStringText

func (h *HexKey) PrintStringText() string

type Number

type Number interface {
	~int | ~int64
}

Jump to

Keyboard shortcuts

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