title: meet M2Crypto.RSA.RSAError: bad signature while using rsa.verify
body: <p>all. I have to verify a signature that signed by PHP, but i'm using python.</p>
  
  <p>here is the code:</p>
  
  <pre><code>e, n = parse_key('publickey(prod).xml')
  rsakey = Crypto.PublicKey.RSA.construct((long(n), long(e)))
  public_key = rsakey.publickey().exportKey()
  bio = M2Crypto.BIO.MemoryBuffer(public_key)
  rsa = M2Crypto.RSA.load_pub_key_bio(bio)
  
  sign = 'E04bby1CgTm4EvTSp3ZXsgb/P/x7YQX90+Rb5sTZe7XItVR5y5ZtQZyVUszNaUS2fiOrepcLrMnAjTSs9mHa7WCpCNvM5baKSARsm2Jgt6orwzYqAKKBxhP3GhV1aMqNV5swpdJmuH4J70qvcE1iCs0ji9rCBmG3ZwPjGukfUoQ='
  unsigned_data = 'merchantId=109060001104024&amp;version=v1.0&amp;language=1&amp;signType=1&amp;issuerId=&amp;paymentOrderId=20110503115316732&amp;orderNo=109060001104024201105031155191155199245&amp;orderDatetime=20110503115519&amp;orderAmount=1&amp;payDatetime=20110503115316&amp;payAmount=1&amp;ext1=&amp;ext2=&amp;payResult=1&amp;errorCode=&amp;returnDatetime=20110503115418'    
  m = EVP.MessageDigest('sha1')
  print m.update(unsigned_data)
  digest = m.final()
  sign = base64.b64decode(sign)
  result = rsa.verify(digest, sign, algo='sha1')
  </code></pre>
  
  <p>here is the error message:</p>
  
  <pre><code>Traceback (most recent call last):
    File "E:\project\site\daybang\allinpay\pub_xml.py", line 38, in &lt;module&gt;
      result = rsa.verify(digest, sign, algo='sha1')
    File "C:\Python25\Lib\site-packages\M2Crypto\RSA.py", line 205, in verify
      return m2.rsa_verify(self.rsa, data, signature, digest_type) 
  M2Crypto.RSA.RSAError: bad signature
  </code></pre>
  
  <p>I can't find out how to generate the good signature from the sign that get from the server(ie the "sign" in my code).
  thx.</p>