Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8098395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:04:07+00:00 2026-06-05T22:04:07+00:00

I am building an application(in java) and I would like to provide myself with

  • 0

I am building an application(in java) and I would like to provide myself with some mesure of its performance. There are multiple long running processes that I am timing, and I have a web server that I will use to receive the metrics, however I would like to create a number that is unique for a particular user(my program doesn’t need to be logged in) on a computer.

So if Joe logged on to computer A and ran my application, It would give him a unique number like 1234. Then if Jane logged on to the same computer it would use a different number, such as 4321. However if Joe logged on to computer B, it would create a separate number entirely, say 5678. Also (just to clarify) If Joe logged back on to computer A, it would still produce the number 1234.

Also, just to make it more challenging, If the same computer was on a different network, then I would preferably want a different ID.

These numbers are arbitrary, and will be longer than this. My code so far generates 8akb7d3n7lp1i1jo6apfhegp593kja5hg38b6o1a5godm38g97omm7bmc3jekc6apopgjhf9g as my UID from:

try {
    byte[] mac = NetworkInterface.getByInetAddress(InetAddress.getLocalHost()).getHardwareAddress();
    String names = new BigInteger(mac).toString(16) + InetAddress.getLocalHost().getHostAddress() + get("user.name") + get("os.version") + get("java.vendor");
    BigInteger uid = new BigInteger(names.getBytes());
    thisUsersUid = uid.toString(26);
} catch (SocketException ex) {
    Logger.getLogger(TimingLogger.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnknownHostException ex) {
    Logger.getLogger(TimingLogger.class.getName()).log(Level.SEVERE, null, ex);
}

I don’t want this information to easily read(as you might figure out names="-f4b86eb8ee1192.168.0.20lee10.6.8Apple Inc.") so I will be adding a hash function to that.

So my question, after all this blurb is: Is this a good way of doing it? Is there a library out there that can do a better job than this? Or am I just wanting too much?

Thanks in advance(even for those comments that say: WHY?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:04:08+00:00Added an answer on June 5, 2026 at 10:04 pm

    Your question is not entirely clear, so I’m going to state some assumptions.

    • Your application is installed on the user’s PC. (It is not an applet or similar that has access limited by sandboxing.)
    • The UID is generated by the application running on the user’s computer, not the server.
    • You don’t need to be able to recover the user’s name and machine identity from the UID; i.e. it is just an opaque identifier.
    • Your solution doesn’t need to be secure. (If the user decides to mess around and generate different UIDs on the same machine, that doesn’t really matter.)

    If so, here are a couple of options.

    • First time you run the application, generate a random UUID and store it in the user’s home directory or preferences or something. Subsequent times, look for an existing UUID in the place where it would have been stored by your application.

    • Generate a UID as a MD5 (or similar) hash of the user’s account name and the machine’s MAC address. This should be stable over restarts … unless there is something weird about the way the user’s PC is implemented.

    (If security is a primary concern then the first approach is not on – you have to assume that the user can find and remove the saved UUID. In the second you have the problem that the user can possibly spoof his account name and/or change the PC’s MAC address. For ANY scheme, you have a bigger problem in that ANY SOFTWARE that is installed or run on a user’s PC could be hacked to replace the UID with something that the user wants. In short, you’re fighting a losing battle if your users have hacker skills and motivation.)


    Is there a library out there that can do a better job than this? Or am I just wanting too much?

    I’m not aware of an existing library that will do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an application using Java and Mysql 5.1. i would like to know
I am building a war-application for WebLogic. I have some property files I would
I am beginning a new Java web application using Netbeans, and I would like
I would like to get your advice. I'm building an application thats going to
I am building a Java EE application using NetBeans 7.1.1. I would prefer to
I'm building a java application which works in a LAN environment, every computer on
I'm building a Java application that has parts that require daily update. I want
I'm building a Web-application in java, with Spring (and spring security), struts2 and hibernate.
I'm building application on Google AppEngine with Java (GAE/J) and all my data will
I am currently building an application using Tomcat, Spring and JAVA. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.