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 8935497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:59:43+00:00 2026-06-15T09:59:43+00:00

I need a unique ID for a document read into a c++ program that

  • 0

I need a unique ID for a document read into a c++ program that will carry into a database. The ID needs to be the same regardless of whether the document it is tied to is run through the program first, by itself, or in the middle of a stack of other documents. So that I can honor overwrites of the document in the database.

I considered using the ASCII value of the document name such as

Employee Spec Page.doc 358

but it has the same value as

Answer Warnings.doc 358

Which means that when I run the second doc in my program, it overwrites the presence of the first doc.

The ID must be a number and needs to be unique but it must be consistently regeneratable without having to cross-reference the database itself (since this program runs separately from the database import program)

Hoping someone has some ideas because I’m stumped.

EDIT: I tried to use MD5 to convert “Employee Spec Page.doc” and “Answer Warnings.doc” and got the following char representations:

Answer Warnings: 2dcb2503c48f5472bfdbafe28d565a9d

Employee Spec Page: a9be4c1428c11b406072c0bd3dab2dee

However, when I then convert the char* into an unsigned int

char* docID = md5.digestString(pDocument->m_csDocumentName.GetBuffer());
pDocument->m_csDocID.Format("%i",(unsigned int)docID);

I get both being:

Answer Warnings: 1634456

Employee Spec Page: 1634456

I got the md5 class from here: http://bobobobo.wordpress.com/2010/10/17/md5-c-implementation/

What am I doing wrong? I need it to be an integer or else I won’t be able to store the ID in the database.

  • 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-15T09:59:45+00:00Added an answer on June 15, 2026 at 9:59 am

    what you need is a hash function generating a number big enough to avoid collisions. MD5 (as piokuc above mentioned) should be ok

    you can generate shorter keys by simply truncating the MD5 result. but be aware that you increase the chance of collisions. 128 bit has more than 10^38 different keys; 64 bit has more than 10^19; 32 bit has more than 10^9 (4.294.967.296). so 32 bit is near a lottery chance to have a collision between two specific documents. for 10.000 documents you have a chance of 1% thave at least one collision. the acceptance of a certain key length depends on your requirements. you can of course implement collision detection and collision resolution.

    if your ‘database’ allows only a short key you have to implement collision resolution. for an idea of how to do that see Hash_table Collision_resolution

    from Wikipedia: ’10^−18 to 10^−15 is the uncorrectable bit error rate of a typical hard disk. In theory, MD5 hashes or UUIDs, being 128 bits, should stay within that range until about 820 billion documents’


    to your concrete library:

    if you look into the md5 header file, there is

    public:
        // an MD5 digest is a 16-byte number (32 hex digits)
        BYTE digestRaw[ 16 ] ;
    

    so you can retrieve the binary digest any time

    MD5 md5;
    char* docID = md5.digestString(pDocument->m_csDocumentName.GetBuffer());
    unsigned int hash_ui = *(unsigned int *)digestRaw;
    

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

Sidebar

Related Questions

I need a program that will be used to send email using SMTP from
I need a unique GUID that never changes per user in active directory... I
I have a word document (docx format) that I need to populate with data
I have an Excel document containing the details of 2000 users that need to
I'm building a database with several collections. I have unique strings that I plan
I am currently pulling data into MongoDB, and will later need to pull this
There are some documents to be indexed, that means I need to read the
I'm trying to read a JSON file into a data structure so that I
I need a unique request ID for my logger, so I can track each
I have a need for unique reusable ids. The user can choose his own

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.