grr/server/grr_response_server/databases/mysql_utils.py
def Hash(value):
  """Calculate a 32 byte cryptographic hash of a unicode string using SHA-256.

  This function allows using arbitrary length strings as primary keys in MySQL.
  Because InnoDB has a 767 bytes size limit, this would not be possible
  otherwise. To keep the result deterministic, do not change the underlying hash
  function.

  Args:
    value: the value to hash.

  Returns:
    32 byte cryptographic hash as bytes.
  """
  encoded = value.encode("utf-8")
  return hashlib.sha256(encoded).digest()
Calculate a 32 byte cryptographic hash of a unicode string using SHA-256.

  This function allows using arbitrary length strings as primary keys in MySQL.
  Because InnoDB has a 767 bytes size limit, this would not be possible
  otherwise. To keep the result deterministic, do not change the underlying hash
  function.

  Args:
    value: the value to hash.

  Returns:
    32 byte cryptographic hash as bytes.
  
Calculate a 32 byte cryptographic hash of a unicode string using SHA-256.
This function allows using arbitrary length strings as primary keys in MySQL.
Because InnoDB has a 767 bytes size limit, this would not be possible
otherwise. To keep the result deterministic, do not change the underlying hash
function.
Calculate a 32 byte cryptographic hash of a unicode string using SHA - 256 . This function allows using arbitrary length strings as primary keys in MySQL . Because InnoDB has a 767 bytes size limit this would not be possible otherwise . To keep the result deterministic do not change the underlying hash function .
def Hash(value):
  encoded = value.encode("utf-8")
  return hashlib.sha256(encoded).digest()
def Hash ( value ) : encoded = value . encode ( "utf-8" ) return hashlib . sha256 ( encoded ) . digest ( )
Calculate a 32 byte cryptographic hash of a unicode string using SHA-256.
Calculate a 32 byte cryptographic hash of a unicode string using SHA - 256 .
"""Calculate a 32 byte cryptographic hash of a unicode string using SHA-256.

  This function allows using arbitrary length strings as primary keys in MySQL.
  Because InnoDB has a 767 bytes size limit, this would not be possible
  otherwise. To keep the result deterministic, do not change the underlying hash
  function.

  Args:
    value: the value to hash.

  Returns:
    32 byte cryptographic hash as bytes.
  """
32 byte cryptographic hash as bytes.
32 byte cryptographic hash as bytes .
value
the value to hash.
the value to hash .