max string lenght for cakephp hash function

118 Views Asked by At

Is there a some maximum length restriction for the string for the cake hash function.

Thanks

1

There are 1 best solutions below

2
JvO On BEST ANSWER

Only available memory (i.e. you have to be able to load the string as a whole). The hash output always has the same length, though.

If you want to hash a large data blob that won't fit into memory you must process it in chunks. PHP has some functions for it (see https://www.php.net/manual/en/ref.hash.php). The basic steps are:

  1. Create a hashing structure (hash_init)
  2. Read chunks, update the hash structure (hash_update)
  3. After the last chunk, finalize the hash and get the output (hash_final)

For your convenience, PHP has hash_update_file and hash_update_stream wrappers.