Add RPC function for encrypting data

This commit is contained in:
2025-05-08 19:46:18 +00:00
parent d4845e53ad
commit 9d7417e26d
6 changed files with 79 additions and 38 deletions
+9 -2
View File
@@ -16,15 +16,22 @@ type RCWService struct{}
// DecryptRequest is the RPC method that decrypts the incoming data using
// the global passphrase and returns the decrypted data
func (h *RCWService) DecryptRequest(request []byte, reply *[]byte) error {
func (h *RCWService) DecryptRequest(encBytes []byte, reply *[]byte) error {
var err error
*reply, err = wrappers.Decrypt(request, globalPassphrase)
*reply, err = wrappers.Decrypt(encBytes, globalPassphrase)
if err != nil {
return err
}
return nil
}
// EncryptRequest is the RPC method that encrypts the incoming data using
// the global passphrase and returns the encrypted data
func (h *RCWService) EncryptRequest(decBytes []byte, reply *[]byte) error {
*reply = wrappers.Encrypt(decBytes, globalPassphrase)
return nil
}
// getFileHash returns the SHA256 hash of the file at the given path.
func getFileHash(path string) []byte {
file, _ := os.Open(path)