Commit ffcaa72e authored by Ajit Jagtap's avatar Ajit Jagtap
Browse files

Merge branch 'CompressionAdded_SSS' into 'master'

Compression added before encryption

See merge request !20
parents f31f8a29 6756664a
Branches
Tags
1 merge request!20Compression added before encryption
Showing with 21 additions and 2 deletions
......@@ -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
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment