diff --git a/.dockerignore b/.dockerignore index afbc551..f8d8061 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ vendor -Dockerfile \ No newline at end of file +Dockerfile +salt.go \ No newline at end of file diff --git a/.gitignore b/.gitignore index 12852ca..3fe9c63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ cmd/portwarden/portwarden_backup/* vendor/* **/*.portwarden -**/*.decrypted.zip \ No newline at end of file +**/*.decrypted.zip +salt.go \ No newline at end of file diff --git a/encryption.go b/encryption.go index 7d9a2e2..89ced60 100644 --- a/encryption.go +++ b/encryption.go @@ -14,8 +14,6 @@ import ( ) const ( - Salt = `,(@0vd<)D6c3:5jI;4BZ(#Gx2IZ6B>` - ErrMessageAuthenticationFailed = "cipher: message authentication failed" ErrWrongBackupPassphrase = "wrong backup passphrase entered" ) diff --git a/utils/generate_salt_file.go b/utils/generate_salt_file.go new file mode 100644 index 0000000..1fb19c6 --- /dev/null +++ b/utils/generate_salt_file.go @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "io/ioutil" + "log" + "os" +) + +const ( + Template = `package portwarden + +const ( + Salt = "%v" +) +` +) + +func main() { + Salt := os.Getenv("Salt") + if len(Salt) == 0 { + log.Fatal("Salt not detected in Environment Variable `Salt`") + } + err := ioutil.WriteFile("./salt.go", []byte(fmt.Sprintf(Template, Salt)), 0644) + if err != nil { + if len(Salt) == 0 { + log.Fatalf("Error writing salt file: %v", err) + } + } + +}