Hash an integer in Python to match Oracle's STANDARD_HASH : <p>In Oracle, my data has been hashed by passing an integer into `STANDARD_HASH' as follows. How can I get the same hash value using Python?</p>

<p>Result in Oracle when an integer passed to STANDARD_HASH:</p>

<pre><code>SELECT STANDARD_HASH(123, 'SHA256') FROM DUAL;
# A0740C0829EC3314E5318E1F060266479AA31F8BBBC1868DA42B9E608F52A09F
</code></pre>

<p>Result in Python when a string is passed in:</p>

<pre><code>import hashlib

hashlib.sha256(str.encode(str(123))).hexdigest().upper()
# A665A45920422F9D417E4867EFDC4FB8A04A1F3FFF1FA07E998E86F7F7A27AE3
# I want to modify this function to get the hash value above.
</code></pre>

<p>Maybe this information will also help. I cannot change anything on the Oracle side, but if I could, I would convert the column to <code>CHAR</code> and it would give the same value as my current Python implementation. An example follows.</p>

<p>Result in Oracle when a string passed to STANDARD_HASH:</p>

<pre><code>SELECT STANDARD_HASH('123', 'SHA256') FROM DUAL;
# A665A45920422F9D417E4867EFDC4FB8A04A1F3FFF1FA07E998E86F7F7A27AE3 (matches Python result)
</code></pre>

<p>I've made several attempts, like simply passing in an integer to Python, but this results in the error that a string is required. I've also searched for a way to encode the integer, but haven't made any progress.</p>
