30 lines
533 B
Go
30 lines
533 B
Go
|
package machineid
|
||
|
|
||
|
import (
|
||
|
"github.com/btcsuite/btcd/btcutil/base58"
|
||
|
"github.com/denisbrodbeck/machineid"
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
const salt = "emissary.cadoles.com"
|
||
|
|
||
|
func Get() (string, error) {
|
||
|
machineID, err := getProtectedMachineID()
|
||
|
if err != nil {
|
||
|
return "", errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
return machineID, nil
|
||
|
}
|
||
|
|
||
|
func getProtectedMachineID() (string, error) {
|
||
|
id, err := machineid.ProtectedID(salt)
|
||
|
if err != nil {
|
||
|
return "", errors.WithStack(err)
|
||
|
}
|
||
|
|
||
|
encoded := base58.Encode([]byte(id))
|
||
|
|
||
|
return encoded, nil
|
||
|
}
|