ag_tools/cmd/rsa/rsa.go

30 lines
841 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package rsa
import (
"archgrid.xyz/ag/tools/types"
"github.com/spf13/cobra"
)
var (
rsaKeyLength types.RSAKeyBits = types.RSA2048
publicKeyFile string
privateKeyFile string
)
var rsaCmd = &cobra.Command{
Use: "rsa",
Short: `RSA加密算法工具`,
Long: `使用RSA算法对给定的内容进行加密或解密生成RSA密钥。`,
TraverseChildren: true,
}
func init() {
rsaCmd.PersistentFlags().VarP(&rsaKeyLength, "key-length", "l", "RSA密钥长度可选值有1024, 2048缺省值为2048。")
rsaCmd.PersistentFlags().StringVarP(&publicKeyFile, "public-key", "u", "", "RSA公钥文件用于加密。")
rsaCmd.PersistentFlags().StringVarP(&privateKeyFile, "private-key", "r", "", "RSA私钥文件用于解密。")
}
func GetRsaCmd() *cobra.Command {
return rsaCmd
}