Documentation
¶
Overview ¶
Package cmd some useful tools for command argument
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DecryptAESCMD = &cobra.Command{ Use: "aes", Short: "decrypt a file written by `encrypt aes`", Long: gutils.Dedent(` decrypt a file written by "encrypt aes". The password-based format is detected by its header. Raw-key files need --key-file. Files written by the removed "-s" flag need --password-file (or the prompt) together with --legacy-password-as-key. `), Args: NoExtraArgs, RunE: func(cmd *cobra.Command, _ []string) error { return runDecryptAES(cmd, &decryptAESArgs) }, }
DecryptAESCMD decrypt files by aes
`go run cmd/main/main.go decrypt aes -i cmd/root.go.enc --password-file ./pw.txt`
View Source
var DecryptCMD = &cobra.Command{ Use: "decrypt", Short: "decrypt file", Long: gutils.Dedent(` decrypt a file encrypted by "encrypt" Run go run main.go decrypt aes -i <file>.enc --password-file <path|-> go run main.go decrypt aes -i <file>.enc --key-file <path|-> go run main.go decrypt aes -i <file>.enc --password-file <path|-> --legacy-password-as-key `), Args: NoExtraArgs, }
DecryptCMD decrypt files
View Source
var EncryptAESCMD = &cobra.Command{ Use: "aes", Short: "encrypt a file or the files of a directory with AES-256-GCM", Long: gutils.Dedent(` encrypt a file, or every regular file directly inside a directory, by AES-GCM. Password mode (--password-file, or the interactive prompt) derives an AES-256 key with Argon2id (t=3, m=64 MiB, p=4) under a fresh random salt and writes a self-describing, versioned format. A directory run derives the key once. Raw-key mode (--key-file) uses a hex-encoded 16/24/32-byte key directly. Outputs are written with mode 0600 via a temporary file and an atomic rename; an existing symlink or special file at the output path is refused. Directory inputs ending in .enc are included by default. Use --skip-suffix-inputs to explicitly exclude them; a suffix alone does not identify encrypted content. `), Args: NoExtraArgs, RunE: func(cmd *cobra.Command, _ []string) error { return runEncryptAES(cmd, &encryptAESArgs) }, }
EncryptAESCMD encrypt files by aes
`go run cmd/main/main.go encrypt aes -i cmd/root.go --password-file ./pw.txt`
View Source
var EncryptCMD = &cobra.Command{ Use: "encrypt", Short: "encrypt file or directory", Long: gutils.Dedent(` encrypt file or directory by aes Usage import ( gcmd "github.com/Laisky/go-utils/v6/cmd" ) func init() { rootCMD.AddCommand(gcmd.EncryptCMD) rootCMD.AddCommand(gcmd.DecryptCMD) } Run go run main.go encrypt aes -i <file_or_dir> --password-file <path|-> go run main.go encrypt aes -i <file_or_dir> --key-file <path|-> go run main.go encrypt aes -i <file_or_dir> # prompts for a password on a terminal `), Args: NoExtraArgs, }
EncryptCMD encrypt files
View Source
var RSA = &cobra.Command{ Use: "rsa", Short: "rsa", Args: NoExtraArgs, Run: func(_ *cobra.Command, _ []string) { }, }
RSA some rsa command tools
View Source
var RSASign = &cobra.Command{ Use: "sign", Short: "sign by RSA & SHA256", Args: NoExtraArgs, RunE: func(_ *cobra.Command, _ []string) error { return errors.Wrap(SignFileByRSA(rsaPrikeyPemFilepath, fileWantToSignature), "sign by rsa") }, }
RSASign sign file by rsa
View Source
var RSAVerify = &cobra.Command{ Use: "verify", Short: "verify by RSA & SHA256", Args: NoExtraArgs, RunE: func(_ *cobra.Command, _ []string) error { return errors.Wrap(VerifyFileByRSA(rsaPubkeyPemFilepath, fileWantToSignature), "verify by rsa") }, }
RSAVerify verify file by rsa
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func NoExtraArgs ¶
NoExtraArgs make sure every args has been processed
do not allow any unprocessed args
Example ¶
use with cobra.Command:
cmd = &cobra.Command{
Args: NoExtraArgs,
}
func SignFileByRSA ¶
SignFileByRSA sign file by rsa
func VerifyFileByRSA ¶
VerifyFileByRSA verify file by rsa
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.