mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
lib/protocol: Use sha256.Sum256 in NewDeviceID (#6775)
This is shorter, skips two allocations, makes the function inlineable and is safer, since the compiler now check whether DeviceIDLength == sha256.Size.
This commit is contained in:
parent
d985aa9e4b
commit
dc145bfad7
@ -33,11 +33,7 @@ func repeatedDeviceID(v byte) (d DeviceID) {
|
||||
|
||||
// NewDeviceID generates a new device ID from the raw bytes of a certificate
|
||||
func NewDeviceID(rawCert []byte) DeviceID {
|
||||
var n DeviceID
|
||||
hf := sha256.New()
|
||||
hf.Write(rawCert)
|
||||
hf.Sum(n[:0])
|
||||
return n
|
||||
return DeviceID(sha256.Sum256(rawCert))
|
||||
}
|
||||
|
||||
func DeviceIDFromString(s string) (DeviceID, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user