package base91 import ( "fmt" "b612.me/starcrypto" "b612.me/starlog" "github.com/spf13/cobra" ) var Cmd = &cobra.Command{ Use: "base91", Short: "使用base91处理文件或字符串", Long: "使用base91处理文件或字符串", Run: func(this *cobra.Command, args []string) { de, _ := this.Flags().GetBool("decode") if len(args) != 1 { starlog.Criticalln("参数不足,请输入文件地址或字符串") return } if !de { data := starcrypto.Base91EncodeToString([]byte(args[0])) fmt.Println(data) } else { var data []byte data = starcrypto.Base91DecodeString(args[0]) fmt.Println(string(data)) } }, } func init() { Cmd.Flags().StringP("out", "o", "", "指定加解码输出地址") Cmd.Flags().BoolP("decode", "d", false, "base91解码") }