Implement AES256+GCM encryption/decryption (cascading)

This commit is contained in:
2025-05-03 18:13:40 -04:00
parent b93acdcaef
commit 146901a479
4 changed files with 102 additions and 12 deletions
+16 -1
View File
@@ -16,6 +16,19 @@ import (
// rcw enc <text> <passwd> : Encrypts the provided text and outputs the ciphertext to encrypted-example.txt
// rcw dec <passwd> : Decrypts the provided file and outputs the plaintext to stdout
// TODO Tests:
// Salt (aes+chacha)
// Nonce (aes+chacha)
// Encryption (individual+combined)
// Decryption (individual+combined)
// RPC password sharing
// TODO Enhancements:
// Keyfile:
// Store:
// Hash of passphrase (prevent user from losing data by accidentally providing incorrect passphrase during encryption)
// Order of algorithms (determined randomly at keyfile generation)
func main() {
switch len(os.Args) {
case 2:
@@ -25,10 +38,12 @@ func main() {
// decrypt file
encBytes, _ := os.ReadFile("encrypted-example.txt")
decBytes := wrappers.DecryptCha(encBytes, []byte(os.Args[2]))
decBytes = wrappers.DecryptAES(decBytes, []byte(os.Args[2]))
fmt.Println(string(decBytes))
case 4:
// encrypt data (from cli args)
encBytes := wrappers.EncryptCha([]byte(os.Args[2]), []byte(os.Args[3]))
encBytes := wrappers.EncryptAES([]byte(os.Args[2]), []byte(os.Args[3]))
encBytes = wrappers.EncryptCha(encBytes, []byte(os.Args[3]))
os.WriteFile("encrypted-example.txt", encBytes, 0644)
default:
// request served data