Skip to content

Commit

Permalink
better name after encryption/decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
mimoo committed Sep 26, 2018
1 parent a5dcbcf commit 9f1517c
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
"fmt"
"io"
"io/ioutil"
"time"
"path/filepath"
"strings"
)

func main() {
Expand Down Expand Up @@ -101,13 +102,23 @@ func main() {
var outFile string

if *decrypt {
outFile = "DECRYPTED_FILE"
var path string
path, outFile = filepath.Split(*inFile)
if filepath.Ext(outFile) == ".encrypted" && len(outFile) > 10 {
fmt.Println(outFile)
outFile = strings.TrimSuffix(outFile, ".encrypted")
fmt.Println(outFile)
} else {
outFile = outFile + ".decrypted"
}
outFile = path + outFile
} else {
outFile = "ENCRYPTED_FILE"
_, outFile = filepath.Split(*inFile)
outFile = outFile + ".encrypted"
}

now := time.Now()
outFile += now.Format("_2006-01-02_03-04-05")
// now := time.Now()
// outFile += now.Format("_2006-01-02_03-04-05")

err = ioutil.WriteFile(outFile, content_after, 0644)

Expand Down

0 comments on commit 9f1517c

Please sign in to comment.