title: Python - which encoding should be applied to a string to be passed to hashlib.sha256()?
body: <p>First I used this function in a pyspark udf and it worked correctly</p>
  <pre><code>def encrypt_hash_col_value(column):
      sha_value = hashlib.sha256(column.encode()).hexdigest()
      return sha_value
  
  spark_udf = udf(encrypt_hash_col_value, StringType())
  
  df_hashed = df.withColumn(&quot;metric_1&quot;, spark_udf(&quot;metric_1&quot;))
  </code></pre>
  <p>However with <code>pandas_udf</code> first I got an error:
  <code>AttributeError: 'Series' object has no attribute 'encode'</code>
  I fixed this by modifying the line <code>hashlib.sha256(column.str.encode()).hexdigest()</code>.</p>
  <p>But now it's failing with <code>TypeError: encode() missing 1 required positional argument: 'encoding'</code>. What encoding should be added as an argument to column.str.encode() in this case?</p>
  <p>When I use column.str.encode(&quot;UTF-8&quot;), getting this error: <code>TypeError: object supporting the buffer API required</code></p>