🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

vc.maxkaya.com/mirrors/hardwareid

Package Overview
Dependencies
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vc.maxkaya.com/mirrors/hardwareid

Go Modules
Version
v0.0.0-20190923123414-c3f8f1d75c38
Version published
Created
Source

hardwareid provides support for reading the unique hardware address of most host OS's

Image of Gopher 47

… because sometimes you just need to reliably identify your hardwares.

GoDoc Go Report Card

Main Features

  • Cross-Platform (tested on Win7+, Debian 8+, Ubuntu 14.04+, OS X 10.6+, FreeBSD 11+)
  • No admin privileges required
  • Hardware independent (no usage of MAC, BIOS or CPU — those are too unreliable, especially in a VM environment)
  • IDs are unique1 to the installed OS

Installation

Get the library with

go get github.com/sandipmavani/hardwareid

You can also add the cli app directly to your $GOPATH/bin with

go get github.com/sandipmavani/hardwareid/cmd/hardwareid

Usage

package main

import (
  "fmt"
  "log"
  "github.com/sandipmavani/hardwareid"
)

func main() {
  id, err := hardwareid.ID()
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(id)
}

Or even better, use securely hashed hardware IDs:

package main

import (
  "fmt"
  "log"
  "github.com/sandipmavani/hardwareid"
)

func main() {
  id, err := hardwareid.ProtectedID("myAppName")
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(id)
}

Function: ID() (string, error)

Returns original hardware address as a string like MM:MM:MM:SS:SS:SS.

Function: ProtectedID(appID string) (string, error)

Returns hashed version of the hardware ID as a string. The hash is generated in a cryptographically secure way, using a fixed, application-specific key (calculates HMAC-SHA256 of the app ID, keyed by the hardware ID).

What you get

This package returns the hardware address mac address of your system.

Do something along these lines:

package main

import (
  "crypto/hmac"
  "crypto/sha256"
  "fmt"
  "github.com/sandipmavani/hardwareid"
)

const appKey = "WowSuchNiceApp"

func main() {
  id, _ := hardwareid.ID()
  fmt.Println(protect(appKey, id))
  // Output: dbabdb7baa54845f9bec96e2e8a87be2d01794c66fdebac3df7edd857f3d9f97
}

func protect(appID, id string) string {
  mac := hmac.New(sha256.New, []byte(id))
  mac.Write([]byte(appID))
  return fmt.Sprintf("%x", mac.Sum(nil))
}

Or simply use the convenience API call:

hashedID, err := hardwareid.ProtectedID("myAppName")

Credits

The Go gopher was created by Denis Brodbeck with gopherize.me, based on original artwork from Renee French.

License

The MIT License (MIT) — Denis Brodbeck. Please have a look at the LICENSE.md for more details.

FAQs

Package last updated on 23 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts