Remove functions that go against usage guidelines

This commit is contained in:
2025-05-08 20:26:11 +00:00
parent d324e62474
commit f447c8a28b
2 changed files with 14 additions and 32 deletions
+4 -22
View File
@@ -6,27 +6,9 @@ import (
"net/rpc" "net/rpc"
) )
// DecryptWithDaemonIfOpen uses the RCW daemon (if one is available) to // GetDec requests the RCW daemon to decrypt the given data.
// decrypt and return data. If no RCW daemon is accessible, nil is returned.
func DecryptWithDaemonIfOpen(encBytes []byte) []byte {
if IsOpen() {
return getDecFromDaemon(encBytes)
}
return nil
}
// EncryptWithDaemonIfOpen uses the RCW daemon (if one is available) to
// encrypt and return data. If no RCW daemon is accessible, nil is returned.
func EncryptWithDaemonIfOpen(decBytes []byte) []byte {
if IsOpen() {
return getEncFromDaemon(decBytes)
}
return nil
}
// getDecFromDaemon requests the RCW daemon to decrypt the given data.
// It returns the decrypted data. // It returns the decrypted data.
func getDecFromDaemon(encBytes []byte) []byte { func GetDec(encBytes []byte) []byte {
conn, client := connectToDaemon() conn, client := connectToDaemon()
defer conn.Close() defer conn.Close()
defer client.Close() defer client.Close()
@@ -39,9 +21,9 @@ func getDecFromDaemon(encBytes []byte) []byte {
return decBytes return decBytes
} }
// getEncFromDaemon requests the RCW daemon to encrypt the given data. // GetEnc requests the RCW daemon to encrypt the given data.
// It returns the encrypted data. // It returns the encrypted data.
func getEncFromDaemon(decBytes []byte) []byte { func GetEnc(decBytes []byte) []byte {
conn, client := connectToDaemon() conn, client := connectToDaemon()
defer conn.Close() defer conn.Close()
defer client.Close() defer client.Close()
+10 -10
View File
@@ -62,11 +62,11 @@ func main() {
fmt.Println(err) fmt.Println(err)
return return
} }
decBytes := daemon.DecryptWithDaemonIfOpen(encBytes) var decBytes []byte
if decBytes == nil { if daemon.IsOpen() {
fmt.Println("No RCW daemon available") decBytes = daemon.GetDec(encBytes)
passphrase := inputHidden("Enter RCW passphrase:") } else {
decBytes, err = wrappers.Decrypt(encBytes, passphrase) decBytes, err = wrappers.Decrypt(encBytes, inputHidden("Enter RCW passphrase:"))
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
@@ -100,11 +100,11 @@ func main() {
// encrypt data (using daemon if available) // encrypt data (using daemon if available)
// rcw enc <data> // rcw enc <data>
decBytes := []byte(os.Args[2]) decBytes := []byte(os.Args[2])
encBytes := daemon.EncryptWithDaemonIfOpen(decBytes) var encBytes []byte
if encBytes == nil { if daemon.IsOpen() {
fmt.Println("No RCW daemon available") encBytes = daemon.GetEnc(decBytes)
passphrase := inputHidden("Enter RCW passphrase:") } else {
encBytes = wrappers.Encrypt(decBytes, passphrase) encBytes = wrappers.Encrypt(decBytes, inputHidden("Enter RCW passphrase:"))
} }
os.WriteFile(outputFile, encBytes, 0600) os.WriteFile(outputFile, encBytes, 0600)
return return