base8_bagua

package module
v0.0.0-...-242d451 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: Apache-2.0 Imports: 3 Imported by: 1

README

base8-bagua

八卦图形base8

install

go get -u github.com/Chyroc/base8-bagua/cmd/...

usage

base8-bagua -h
NAME
     base8-bagua -- Encode and decode using Base8-Bagua representation

SYNOPSIS
     base8 [-D|-h]
echo 'hello base8-bagua' | base8-bagua
☳☲☰☶☲☵☵☴☳☳☰☶☷☴☴☰☳☰☴☶☰☵☶☳☳☱☲☳☴☰☵☵☳☰☴☶☰☵☴☷☳☵☲☶☰☴

echo '☳☲☰☶☲☵☵☴☳☳☰☶☷☴☴☰☳☰☴☶☰☵☶☳☳☱☲☳☴☰☵☵☳☰☴☶☰☵☴☷☳☵☲☶☰☴' | base8-bagua -D
hello base8-bagua

解释

符号对应数字
符号 卦名 拼音 8进制数
qián 0
duì 1
2
zhèn 3
xùn 4
kǎn 5
gèn 6
kūn 7
encode
  • string转成byte数组
  • byte转二进制,拼接byte数组为二进制数组
  • 3个二进制数为一个单位,划分成n份(最后补0)
  • 将每个单位转化成8进制数字(3位二进制范围:0-7)
  • 根据上表的对应关系,换成八卦符号
  • 返回八卦符号字符串
decode
  • 将八卦符号字符串转成8进制数数组
  • 将8进制数字转换成3个二进制数,组成二进制数组
  • 以8个二进制数为一个byte,组成byte数组
  • 返回byte数组

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

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

func Encode

func Encode(src []byte) string

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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