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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:26:29+00:00 2026-05-27T14:26:29+00:00

I have a database stored in memory of different files headers. I would like

  • 0

I have a database stored in memory of different files headers. I would like to test the signature of a given file for example a .jpg to those signatures in the database.

Consider that scenario, the signature of the file to be tested is FFD8FFE0, but in the database, there is only a partially matched signature of FFD8FF, and some times, the database has also a signature of FFD8, but to a different type but to the same file format.
How do I correctly retrieve the correct matched signature of the tested file ?

I wrote the following function but it doesn’t work in all file formats.

 public static boolean searchSignature(File file, List<FileSignature> db) throws FileNotFoundException, IOException {

        byte[] buffer = new byte[MAX_SIGNATURE_SIZE];
        InputStream in = new FileInputStream(file);
        int n = in.read(buffer, 0, MAX_SIGNATURE_SIZE);
        String hex  = toHex(buffer);
        boolean b = true;

        // for each signature in the database, compare it with file's siganture
        for (FileSignature fs : db) {
             if (!fs.getSignature().contains(hex)) {
                b = false;

            }
        }
        return b;
    }
  • 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-05-27T14:26:29+00:00Added an answer on May 27, 2026 at 2:26 pm

    Your condition should be

    if ( hex.startsWith( fs.getSignature() ) 
    

    Since hex is longer than the signature from your DB.

    If you have both FFD8FF and FFD8 you can’t differentiate between the longer and shorter signature.

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

Sidebar

Related Questions

I have a setting stored in database which has a value .jpg|.gif|.png . I
I have sql database stored on a shared netwrok drive , after set of
Can I host an application in Windows Azure and have the database stored on
I've got an MS-Access database stored in a folder (yes, I have 'Modify' permissions
I have a very odd issue. When I execute a specific database stored procedure
I have a database which contains picture data stored as a binary blob. The
I have a database with DateTime fields that are currently stored in local time.
We have a large database containing a lot of stored procedures. Now we are
I have a huge database with 100's of tables and stored procedures. Using SQL
I have a huge database with some 100 tables and some 250 stored procedures.

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.