'Pypy SHA256 way to convert hash token data from hexdigest version to hex version

I'm trying to learn length extension attacks, using the Python Implementation of SHA256 from Pypy (here).

As part of the attack, I have access to a SHA256 hex token and I wish to re-use it as an Initialization Vector (IV) for appending the next "string" and padding.

token = '96ef293fdc1cee33ab9b56b13c2a626927c95da2d391c71cf99a2317aaa31408'

However, I can't seem to figure out any way to change the state of SHA256 model. One way I think I can achieve the above task is by hard-coding the known token as IV in the SHA256 model's digest. But I am having a hard time understanding how to translate my Hex Token to the form expected in the digest.

img of sha256 model from pypy

Excuse me for any missing information, let me know if anything else would help to understand my query better!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source