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"
)
// DecryptWithDaemonIfOpen uses the RCW daemon (if one is available) to
// 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.
// GetDec requests the RCW daemon to decrypt the given data.
// It returns the decrypted data.
func getDecFromDaemon(encBytes []byte) []byte {
func GetDec(encBytes []byte) []byte {
conn, client := connectToDaemon()
defer conn.Close()
defer client.Close()
@@ -39,9 +21,9 @@ func getDecFromDaemon(encBytes []byte) []byte {
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.
func getEncFromDaemon(decBytes []byte) []byte {
func GetEnc(decBytes []byte) []byte {
conn, client := connectToDaemon()
defer conn.Close()
defer client.Close()
+10 -10
View File
@@ -62,11 +62,11 @@ func main() {
fmt.Println(err)
return
}
decBytes := daemon.DecryptWithDaemonIfOpen(encBytes)
if decBytes == nil {
fmt.Println("No RCW daemon available")
passphrase := inputHidden("Enter RCW passphrase:")
decBytes, err = wrappers.Decrypt(encBytes, passphrase)
var decBytes []byte
if daemon.IsOpen() {
decBytes = daemon.GetDec(encBytes)
} else {
decBytes, err = wrappers.Decrypt(encBytes, inputHidden("Enter RCW passphrase:"))
if err != nil {
fmt.Println(err)
return
@@ -100,11 +100,11 @@ func main() {
// encrypt data (using daemon if available)
// rcw enc <data>
decBytes := []byte(os.Args[2])
encBytes := daemon.EncryptWithDaemonIfOpen(decBytes)
if encBytes == nil {
fmt.Println("No RCW daemon available")
passphrase := inputHidden("Enter RCW passphrase:")
encBytes = wrappers.Encrypt(decBytes, passphrase)
var encBytes []byte
if daemon.IsOpen() {
encBytes = daemon.GetEnc(decBytes)
} else {
encBytes = wrappers.Encrypt(decBytes, inputHidden("Enter RCW passphrase:"))
}
os.WriteFile(outputFile, encBytes, 0600)
return