cmds

package
v0.0.0-...-9a163b4 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DecryptCmd = &cobra.Command{
	Use:   "decrypt",
	Short: "Decrypt File or Directory",
	Args:  enc_dec_ArgsValidator,
	Run: func(cmd *cobra.Command, args []string) {
		pwds, err := util.ScanEncPwd(false)
		if err != nil {
			return
		}

		_, decPwds, err := crypto.Chaos(pwds)
		if err != nil {
			logger.Error(err)
			return
		}

		if file != "" {
			if err := decrypt(file, decPwds); err != nil {
				return
			}
		}

		if dir != "" {
			err := filepath.Walk(dir, func(file string, info os.FileInfo, err error) error {
				if info.IsDir() {
					return nil
				}

				return decrypt(file, decPwds)
			})

			if err != nil {
				return
			}
		}

		fmt.Println("decrypt success")
	},
}
View Source
var EncryptCmd = &cobra.Command{
	Use:   "encrypt",
	Short: "Encrypt File or Directory",
	Args:  enc_dec_ArgsValidator,
	Run: func(cmd *cobra.Command, args []string) {
		pwds, err := util.ScanEncPwd(true)
		if err != nil {
			return
		}

		_, encPwds, err := crypto.Chaos(pwds)
		if err != nil {
			logger.Error(err)
			return
		}

		if file != "" {
			if err := encrypt(file, encPwds); err != nil {
				return
			}
		}

		if dir != "" {
			err := filepath.Walk(dir, func(file string, info os.FileInfo, err error) error {
				if info.IsDir() {
					return nil
				}

				return encrypt(file, encPwds)
			})

			if err != nil {
				return
			}
		}

		fmt.Println("encrypt success")
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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