Giter Site home page Giter Site logo

csharp-uhwid's Introduction

C# Unique Hardware ID

C# class to generate an Unique Hardware ID.

Sometimes is required create unique identifiers for PCs. There are different approaches for doing that, the most basic among these is to use hardware IDs since they're constant (at most of time).

The most popular are the First Drive Volume ID and the processor ID, using the Windows Management Instrumentation (WMI) infrastructure.

This simple class (about 8kb) generates two unique IDs.

  1. SimpleUID, a concatenation of the First Drive Volume ID and the processor ID.
  2. AdvancedUID, the simpleUID plus a MD5 hash of the Windows build version.

Notes:

  • In Virtualized environments (eg. VirtualBox, VMware, etc) the processor is not available through the WMI. Thus, the class implements an inline Assembly solution (credits to: http://stackoverflow.com/questions/16460485/inline-assembly-code-to-get-cpu-id).
  • The MD5 hash is generated using the Windows codename and the build number in order to avoid repetition when the build number is the same for 2 or more different operating systems. E.g. Windows 7 & Windows Server 2008 had the same build number. You can check out an approximate list of the Windows Version Numbers on http://www.gaijin.at/en/lstwinver.php.
  • The project files and the solution files were intentionally made in Visual C# 2010 Express for convenience of users, and targets to .NET Framework 2.0 x86 with compatibility purposes.

CONSIDERATIONS

  • DO NOT use any of the generated UIDs for production environments, since the code is public, anyone can replicate the UID. It's STRONGLY RECOMMENDED to scramble/encrypt the generated UID with a application specific algorithm.
  • AVOID use external libraries (like this) to generate & validate licenses, due to anybody could patch the dll file to break your licensing system.

Links

Requirements:

  1. .NET Framework 2.0+
  2. Visual C# 2010 Express (and later).

Download:

How to Use:

  1. a) Compile the downloaded code and reference the DLL in your project, or

  2. b) Add the file /UHWID/UHWID.cs to your project.

  3. Add the namespace UHWID where you'll use the class.

    using UHWID;
  4. Get any of the UIDs

    String SimpleUID = UHWIDEngine.SimpleUID;
    String AdvancedUID = UHWIDEngine.AdvancedUID;

Support

Drop me line on: [email protected]

Donations

Did this project help you to save (or earn) some money?
Please, support to the author by making a small donation.

Buy Me A Coffee :) @ PayPal

csharp-uhwid's People

Contributors

davcs86 avatar l4km47 avatar

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.