title: Different results for SHA-1 hashing between Groovy and Python
body: <p>This question is related to my query titled "Create WS security headers for REST web service in SoapUI Pro". However that one is different as I raised that because I couldn't get the script to work at all, I came up with a solution for that but it only works about 66% of the time.</p>
  
  <p>I have noticed that the code that I use to hash the string <em>sometimes</em> produces different results when compared to a python script hashing the same input. </p>
  
  <p>Below is my groovy code that hashes an input value.</p>
  
  <pre><code>MessageDigest cript2 = MessageDigest.getInstance("SHA-1");
          cript2.update(nonce.getBytes("ASCII"));
          PasswordDigest = new String(cript2.digest());
  </code></pre>
  
  <p>If I run it with the input nonce value 201703281329 it produces the below 
  ë±ËËÐùìÓ0¼ÕM�¹,óßP‹</p>
  
  <p>If I use the same input value using the Python code below then it produces ëﾱËËÐùìÓ0ﾼÕMﾏﾹ,óßPﾋ</p>
  
  <pre><code>digest = sha.new(nonce).digest()
  </code></pre>
  
  <p>However if I run the groovy and python scripts with input value 201703281350 then they both produce ..</p>
  
  <p>iàvè©®É¹m:F Ë Â¾</p>
  
  <p>Could someone tell me why I am seeing differences for some input values and not others and how I can modify my groovy code so that it produces same values as Python code?</p>
  
  <p>much appreciated.</p>