mirror of
https://github.com/rwinkhart/rcw.git
synced 2026-08-28 04:46:42 -04:00
29 lines
587 B
Go
29 lines
587 B
Go
package daemon
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
var daemonHash []byte
|
|
var globalPassphrase string
|
|
|
|
// RCWService provides an RPC method.
|
|
type RCWService struct{}
|
|
|
|
// GetPass is the RPC method.
|
|
// For now (as a test/example), it returns "hello" if the input is "hi".
|
|
func (h *RCWService) GetPass(request string, reply *string) error {
|
|
*reply = globalPassphrase
|
|
return nil
|
|
}
|
|
|
|
// getFileHash returns the SHA256 hash of the file at the given path.
|
|
func getFileHash(path string) []byte {
|
|
file, _ := os.Open(path)
|
|
hash := sha256.New()
|
|
io.Copy(hash, file)
|
|
return hash.Sum(nil)
|
|
}
|