0

Assume that we have (know):

  1. Hash(A)
  2. Length of A
  3. A's character type ([0->9],[a->z])
  4. A is a string
  5. Everything about B (original string, Length, etc.)
  6. HashMethod SHA256
  7. Note: A's original value is unknown

Is there a way to use that information to create Hash(A||B) [|| is concatenate {"a" || "b" -> "ab" for example}]

2 Answers2

4

Is there a way to use that information to create Hash(A||B)

No, it is not. However, we can come close: we can compute Hash(A||PadA||B), where PadA is a string that depends on the length of A (but not on its contents). This is known as the 'length extension attack' on SHA256.

poncho
  • 154,064
  • 12
  • 239
  • 382
0

If the output needs to be a SHA256 digest then there's not much you can do except what is mentioned by @poncho. But if you want to use SHA256 in a Merkle tree then you can chunk A up into small pieces and make a Merkle root out of it, this is your Hash(A). When B is available you do the same. Finally, you hash those two Merkle roots together to create Hash(A||B). Of course, the length of A and B should be the same ideally.

lamba
  • 1,395
  • 8
  • 18