refactoring
This commit is contained in:
1 parent
c94a2042f1
commit
c9f416dbd3
7 files changed
+36
-19
No files matched your search
@@ -3,20 +3,34 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/didiercrunch/ecrypto/keygenerator"
|
||||
"os"
|
||||
)
|
||||
|
||||
const VERSION = "0.0.1"
|
||||
|
||||
var createKeyCommand = cli.Command{
|
||||
Name: "createkey",
|
||||
Usage: "create a pair of public/private key",
|
||||
Flags: []cli.Flag{
|
||||
cli.IntFlag{Name: "size, s", Value: 2048, Usage: "key size in bits"},
|
||||
cli.StringFlag{Name: "password, p", Value: "", Usage: "password to access the private key"},
|
||||
},
|
||||
Action: func(c *cli.Context) {
|
||||
keyGenerator := new(KeyGenerator)
|
||||
keyGenerator := new(keygenerator.KeyGenerator)
|
||||
fmt.Println("creating key")
|
||||
if err := keyGenerator.CreateNewKey(c.Int("size")); err != nil {
|
||||
fmt.Println("error while creating the key\n", err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var encryptFileCommand = cli.Command{
|
||||
Name: "encrypt",
|
||||
Usage: "encrypt file or directory",
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{Name: "file, s", Value: "", Usage: "the file or directory to encrypt."},
|
||||
cli.StringFlag{Name: "publicKey, k", Value: "", Usage: "the public key to use to encrypt"},
|
||||
},
|
||||
Action: func(c *cli.Context) {
|
||||
keyGenerator := new(keygenerator.KeyGenerator)
|
||||
fmt.Println("creating key")
|
||||
if err := keyGenerator.CreateNewKey(c.Int("size")); err != nil {
|
||||
fmt.Println("error while creating the key\n", err)
|
||||
@@ -30,6 +44,7 @@ func main() {
|
||||
app.Usage = "encrypt files"
|
||||
app.Commands = []cli.Command{
|
||||
createKeyCommand,
|
||||
encryptFileCommand,
|
||||
}
|
||||
|
||||
app.Run(os.Args)
|
||||
|
||||
Reference in new issue
Block a user