GithubHelp home page GithubHelp logo

saeidjoker / libc.hwid Goto Github PK

View Code? Open in Web Editor NEW
62.0 4.0 14.0 90 KB

generate unique hardware id in C#

License: MIT License

C# 94.93% Batchfile 2.50% Shell 2.58%
hardware hwid ubuntu windows nuget libc

libc.hwid's Introduction

libc.hwid

C# cross platform hardware ID generator

Unique hardware ID generator for protecting your distributed .net software (Ubuntu, Windows & Mac OS Big Sur)

Why we need this?

  • We want to distribute a software and we worry about possible copyright violations.
  • We don't want your software to be distributed without our consent

How does it work?

  • HwId.Generate() method combines Motherboard info with CPU ID into a string
  • Then hashes the string into a 40 character ASCII string. This final string value is the Hardware ID

Considerations:

  • So called Hardware ID, created with HwId.Generate() method, will return the same value on a computer system as long as the mother board and CPU do not change
  • This library does not use Mac address since the value returned from WMI on Microsoft Windows will change if the computer's network connection is lost or disabled.

I've used this piece of code in my projects on the following operating systems:

  • Ubuntu 16.04
  • Ubuntu 18.04.1 LTS
  • Windows 7
  • Windows 7 SP1
  • Windows 8
  • Windows 8.1
  • Windows 10
  • MacOS Big Sur

Usage:

The nuget package is written as a .Net Standard 2.0 & .Net 5.0 class library, so you can use it in the following project types:

  • .Net Standard 2.0+
  • .Net 5.0
  • .Net Core 2.0+
  • .Net Framework 4.6.1+

Just add this nuget package to your project and use as below:

var hardwareId = libc.hwid.HwId.Generate();

Take a look at tests to understand the usage better

libc.hwid's People

Contributors

byte-stealer avatar keytrap-x86 avatar sfmohassel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

libc.hwid's Issues

sudo permissions on Linux

On Linux, the Generate() function needs sudo permissions to run.
There is no async function to wait until the user entered the password for console applications.

Getting exception thrown on Arch Linux e.g: Manjaro XFCE (Virtual Machine)

Hi, on freshly installed Manjaro XFCE VM I get the following exception

Unhandled exception. System.TypeInitializationException: The type initializer for 'TEST.Program' threw an exception.
---> System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable'1 source, Func'2 predicate)
at libc.hwid.HwId.Dmidecode(String query, String find)
at libc.hwid.HwId.GetInfo(Hardware hw)
at libc.hwid.HwId.Generate()

How is the code used
I have the class User with the field public static string UUID
In that class there is a constructor that has the following code

public User() { UUID = libc.hwid.HwId.Generate(); }
The exception is thrown when I create a new user object with
static User user = new User();

This works fine on windows

Do cloned PCs have the same ID ?

Hello,
In the case of identical PCs with same MotherBoard and CPU, and a clone of the system image, will the generated ID be the same?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.