mirror of
https://github.com/rwinkhart/rcw.git
synced 2026-08-28 04:46:42 -04:00
Implement AES256+GCM encryption/decryption (cascading)
This commit is contained in:
+16
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user