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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:11:38+00:00 2026-05-14T05:11:38+00:00

If my math is right, I can quickly generate a new hash value for

  • 0

If my math is right, I can quickly generate a new hash value for the concatenation of two strings if I already have the individual hash values for each string. But only if the hash function is of the form:

hash(n) = k * hash(n-1) + c(n), and h(0) = 0.

In this case,

hash( concat(s1,s2) ) = k**length(s2) * hash(s1) + hash(s2)

eg.

h1  = makeHash32_SDBM( "abcdef",          6 );
h2  = makeHash32_SDBM( "ghijklmn",        8 );
h12 = makeHash32_SDBM( "abcdefghijklmn", 14 );
hx  = mod32_powI( 65599, 8 ) * h1 + h2;

h1  = 2534611139
h2  = 2107082500
h12 = 1695963591
hx  = 1695963591

Note that h12 = hx so this demonstrates the idea.

Now, for the SDBM hash k=65599. Whereas the DJB hash has k=33 (or perhaps 31?) and h(0) = 5381 so to make it work you can set h(0) = 0 instead.

But a modification on the DJB hash uses xor instead of + to add each character.

http://www.cse.yorku.ca/~oz/hash.html

Is there another technique to quickly calculate the hash value of concatenated strings if the hash function uses xor instead of +?

  • 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-14T05:11:39+00:00Added an answer on May 14, 2026 at 5:11 am

    That would be true if your second hash will be function of initial state of hash. For some kinds of hash-function it’s easy to shift them according to new initial state (like xor’e words, or their sum etc). But in general case that’s almost impossible (in other case use of hash+”salt” in password matching will be easier to break).

    But usually you can use result of hashing of first string and than continue feeding data from second string.

    Update:
    I guess there is no way to find f(x,y) for:

    h_abc = hashOf(h0, "abc")  
    h_def = hashOf(h0, "def")  
    (h_abcdef = f(h_abc, h_def)) == hashOf(h0, "abcdef")  
    

    But you able to:

    h_abc = hashOf(h1, "abc")  
    (h_abcdef = hashOf(h_abc, "def")) == hashOf(h0, "abcdef")  
    

    one of the reason for why you can’t do that is that “33” isn’t power of “2”. If it will use “32” (2**5), then:

    h_abcdef == (h_abc << (5*len(abc))) xor h_def
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.