Results 1 to 10 of 10

Thread: The unique key

  1. #1
    Join Date
    Jan 2008
    Location
    Russia, Tver
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default The unique key

    Hello all Sorry for my English, i am from Russia )
    I have got a problem. I need a crossplaform method to generate some unique per machine key. I will use it in my RC4 crypt algorithm as a crypt key.
    In Windows, I know, there is something like WinId, but what to do in Linux and Mac?
    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: The unique key

    WinId is the platform window handle id, and it most certainly will not be unique between sessions.

    For your need QUuid is more suitable.

  3. #3
    Join Date
    Jan 2008
    Location
    Russia, Tver
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: The unique key

    I know about QUuid, but i also keno that it is not cryptographic-quality random number generator.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: The unique key

    Quote Originally Posted by igor.alexandrov View Post
    I know about QUuid, but i also keno that it is not cryptographic-quality random number generator.
    And how is WinId better than a GUID?

    If you want to use "cryptographic-quality random number generator" then take a look at libgcrypt at http://www.gnupg.org/

  5. #5
    Join Date
    Jan 2008
    Location
    Russia, Tver
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: The unique key

    No, no, I really don't think that WinId is better then QUuid. It was just an example About GnuPG, thanks, I forget about it.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: The unique key

    Just generate a large random number and test it for being prime. You don't need Qt for that.

  7. #7
    Join Date
    Jan 2006
    Location
    Socorro, NM, USA
    Posts
    29
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: The unique key

    I know it is a bit late, but...

    If it is just about a random number, Linux has a two very nice devices which provide you with entropy based rand numbers. Check the man page (man urandom). If it is about random uuids, read the (publicly readable) file /proc/sys/kernel/random/uuid. This file creates on every read access a new random uuid.

    Cheers,
    Thomas
    There are 10 people in the world. Those who understand binary and those who don't.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: The unique key

    I just read the original question again. You are using RC4, so your large number doesn't even have to be prime. If you want a custom random number generator, you can find some in "Numerical Recipes in C".

  9. #9
    Join Date
    Jan 2006
    Location
    Socorro, NM, USA
    Posts
    29
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: The unique key

    Quote Originally Posted by wysota View Post
    I just read the original question again. You are using RC4, so your large number doesn't even have to be prime. If you want a custom random number generator, you can find some in "Numerical Recipes in C".
    But the code in Numerical Recipies is not free, so it limits the usage pretty much. For instance the project I am working for cannot use those code snippets because our software is GPL.
    There are 10 people in the world. Those who understand binary and those who don't.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: The unique key

    Who said you should take the code? The algorithm is what is important, the code can be written from scratch. Once you get a grip of how random number generators work (that they are shift registers with feedback), you can design (and implement) your own.

Similar Threads

  1. ContextMenu Very unique GUI.
    By VireX in forum Qt Programming
    Replies: 14
    Last Post: 15th April 2007, 08:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.