PHP » PYTHON |
login |
register |
about
|
#Python 2.7 import hashlib algo = 'ripemd160' data = 'The quick brown fox jumped over the lazy dog.' h = hashlib.new(algo) h.update(data) When you want to get digest as hex string, result = h.hexdigest() # result will be '8eb208f7e05d987a9b044a8e98c6b087f15a0bfc' or as raw binary, result = h.digest() # result will be '\x8e\xb2\x08\xf7\xe0]\x98z\x9b\x04J\x8e\x98\xc6\xb0\x87\xf1Z\x0b\xfc' hash(PHP 5 >= 5.1.2, PECL hash >= 1.1) hash — Generate a hash value (message digest) Description
string hash
( string $algo
, string $data
[, bool $raw_output= false
] )
Parameters
Return ValuesReturns a string containing the calculated message digest as lowercase hexits unless raw_output is set to true in which case the raw binary representation of the message digest is returned. Examples
Example #1 A hash() example
<?php The above example will output: ec457d0a974c48d5685a7efa03d137dc8bbde7e3
See Also
|
more
Recently updated
more
Most requested
more
Last requests
|