Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
coreospackage
Commits
6756664a
Commit
6756664a
authored
7 years ago
by
Sandeep S. Shewalkar
Browse files
Options
Downloads
Patches
Plain Diff
Compression added before encryption
parent
f31f8a29
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!20
Compression added before encryption
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dalhelper/dalFDB.go
+21
-2
dalhelper/dalFDB.go
with
21 additions
and
2 deletions
dalhelper/dalFDB.go
+
21
−
2
View file @
6756664a
...
...
@@ -256,9 +256,15 @@ func GetDataFromFDB(filePath string) ([]byte, error) {
keyBytes
:=
GetKeyWithFileNameAndDefaultKey
(
filePath
)
decryptedData
,
decryptionError
:=
securityhelper
.
AESDecrypt
(
data
,
keyBytes
)
if
decryptionError
!=
nil
{
logginghelper
.
LogError
(
"Error while decrypting data of "
,
filePath
,
" : "
,
decryptionError
)
return
nil
,
decryptionError
}
return
decryptedData
,
nil
decompressedData
,
decompressError
:=
securityhelper
.
Decompress
(
decryptedData
)
if
decompressError
!=
nil
{
logginghelper
.
LogError
(
"Error while decompressing data of "
,
filePath
,
" : "
,
decompressError
)
return
nil
,
decompressError
}
return
decompressedData
,
nil
}
return
data
,
err
}
...
...
@@ -281,15 +287,28 @@ func SaveDataToFDB(filePath string, data []byte, makeDir bool) error {
// encryptedData, encryptionError := securityhelper.AESEncryptDefault(data)
keyBytes
:=
GetKeyWithFileNameAndDefaultKey
(
filePath
)
encryptedData
,
encryptionError
:=
securityhelper
.
AESEncrypt
(
data
,
keyBytes
)
compressedText
,
compressionError
:=
securityhelper
.
Compress
(
data
)
if
compressionError
!=
nil
{
logginghelper
.
LogError
(
"Error while compressing data of "
,
filePath
,
" : "
,
compressionError
)
return
compressionError
}
encryptedData
,
encryptionError
:=
securityhelper
.
AESEncrypt
(
compressedText
,
keyBytes
)
if
encryptionError
!=
nil
{
logginghelper
.
LogError
(
"Error while encrypting data of "
,
filePath
,
" : "
,
encryptionError
)
return
encryptionError
}
fileWriteError
:=
filehelper
.
WriteFile
(
filePath
,
encryptedData
)
if
fileWriteError
!=
nil
{
logginghelper
.
LogError
(
"Error while writing data to "
,
filePath
,
" : "
,
fileWriteError
)
}
return
fileWriteError
}
err
:=
filehelper
.
WriteFile
(
filePath
,
data
)
if
err
!=
nil
{
logginghelper
.
LogError
(
"Error while writing data to "
,
filePath
,
" : "
,
err
)
}
return
err
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets