Let's cache the scancodes and flush them at the end. Also make sure to send only as many as the driver can send correctly. It's important here to chunk the scancodes correctly, so that we don't accidentally split them over successive calls to the driver
18 lines
315 B
Go
18 lines
315 B
Go
package objx
|
|
|
|
import (
|
|
"crypto/sha1"
|
|
"encoding/hex"
|
|
)
|
|
|
|
// HashWithKey hashes the specified string using the security
|
|
// key.
|
|
func HashWithKey(data, key string) string {
|
|
hash := sha1.New()
|
|
_, err := hash.Write([]byte(data + ":" + key))
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return hex.EncodeToString(hash.Sum(nil))
|
|
}
|