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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:02:49+00:00 2026-06-02T03:02:49+00:00

I would like to save a md5 of a image file in a database

  • 0

I would like to save a md5 of a image file in a database so when a user sends another image I would like to be able to compare if the image already exists in the database, I have to know if theres already one of those in the database, I thought the easiest way would be to md5 the content of a file and then compare with the md5 output to see if they are equal or not.

how could I do that? if you think this is not very good to do, you could suggest something else to compare images without having the original file present at the moment, that’s why I’m saving the md5 in the database.

I have the md5 function but I don’t know what to md5, my md5 function accept a std::string parameter and return the result as a std::string.

Thank you in advance.

  • 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-02T03:02:51+00:00Added an answer on June 2, 2026 at 3:02 am

    I think MD5 is the way to go. Any image processing operation to compare images will probably take longer than the MD5 calculation.

    Now, you need to break this operation into smaller steps:

    1 – Read a file in binary mode into a std::string:

    string data;
    string filename("file.bin");
    ifstream input_file( filename.c_str(), ios::binary | ios::in );
    if( !input_file)
    {
        cout << "!!! Failed to open file";
        // exit/return
    }
    
    std::ostringstream ss;
    ss << input_file.rdbuf();
    data = ss.str();
    
    input_file .close();
    

    2 – Retrieve the MD5 of the file:

    std::string md5_hash = compute_md5(data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to save user messages to a database. The message will be
I would like to save data to database only once per user, based on
I would like to save the programs settings every time the user exits the
I would like to save data in cookies (user name, email address, etc...) but
I have a plist where I would like to save a some response details
I have created a MySQL table and would like to save the contents of
I have an ASP.Net form and i would like to save it into a
I would like to know the best way to save an image from a
I would like to save a file downloaded from the internet in iPhone. Can
I would like to save objects that the user adds to a NSMutableArray that

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.