I have a piece of code in Scala which I need to convert into Python:
import java.nio.ByteBuffer
import java.nio.charset.Charset;
val string = Array(28087,33,580,21,"a2aa639d-6b3a-4844-b343-8d1b335af21b",9,1,1,0,1,0,0,0,1).mkString("|")
val digester = java.security.MessageDigest.getInstance("SHA-1")
val hashBytes = digester.digest(string.getBytes(Charset.forName("UTF-8")))
val bb = ByteBuffer.allocate(java.lang.Long.BYTES)
bb.put(hashBytes, 0, java.lang.Long.BYTES)
bb.flip()
bb.getLong()
So, this gives the output -3586932978655362506. Now I am trying to convert this in Python to get the same results
import hashlib
s = "28087|33|580|21|a2aa639d-6b3a-4844-b343-8d1b335af21b|9|1|1|0|1|0|0|0|1"
hashBytes = hashlib.sha1(bytearray(s, 'utf-8')).digest()
### need the code for bytebuffer ###
For bytebuffer in Python, I am trying to use PyByteBuffer but not able to find the corresponding functionality. Any help in this regard?