30 lines
841 B
Go
30 lines
841 B
Go
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
|
|
}
|