Does python Sha1 takes integer
<p>How to take integer in hashlib.sha1(int).
Please see the code in which i am taking IP as string converting it as integer now at hash.sha1 doest take integer...</p>

<pre><code> import hashlib
 import socket
 import struct
  class blommy(object):
   def __init__(self):
    self.bitarray= [0]*2048

  def hashes(self,ip):
    #convert decimal dotted quad string to long integer"
    intip= struct.unpack('&gt;L',socket.inet_aton(ip))[0]
    index = [0, 1]
    hbyte = hashlib.sha1(intip) # how to take sha1 of integer??
    index[0] = ord(hbyte[0])| ord(hbyte[1])&lt;&lt; 8
    index[1] = ord(hbyte[2])| ord(hbyte[3])&lt;&lt; 8
</code></pre>

<hr>

<p>Need to convert this C code to python. Please advice some part of code is written above. If i take ip as int I cannot compute sha1 + even if convert ip using socket than sha1 dont accept it suggestion? see comments below</p>

<pre><code>//fixed parameters
k = 2

m = 256*8

  //the filter
  byte[m/8] bloom   ## 

 function insertIP(byte[] ip) {

byte[20] hash = sha1(ip)

int index1 = hash[0] | hash[1] &lt;&lt; 8 # how to in python?
int index2 = hash[2] | hash[3] &lt;&lt; 8

// truncate index to m (11 bits required)
index1 %= m  ## ?
index2 %= m  ## ?

// set bits at index1 and index2
bloom[index1 / 8] |= 0x01 &lt;&lt; index1 % 8   ## ??
bloom[index2 / 8] |= 0x01 &lt;&lt; index2 % 8   ## ??
}

 // insert IP 192.168.1.1 into the filter:
    insertIP(byte[4] {192,168,1,1})
</code></pre>
