possible collision hashing uuid cakephp


Is it possible to have collisions if to use Security::hash on uuid() string ? I know that uuid() generates truly unique string, but I need them to be hashed, and I am worried if there is a possibility that the hashed string can be repeated.



Firstly, contrary to the name, a uuid does not create a truly unique string. It generates a string that is unique with very high probability(high enough that it can for pretty much all purposes be treated as unique).

As for your chances of getting a collision, that really depends on which hashing algorithm you are using. Assuming a well built hashing algorithm which distributes uniformly over it's output space, your odds of a collision with any two hashes is 1 / 2^n where n is the hash length in bits. The odds of any two hashes colliding in a birthday attack scenario can be approximated using the formula p(h) = h^2 / 2 m where h is the number of hashes you expect to generate and m is the output space (2^256 in the case of SHA256 for example).

So, the sum it all up, you will <strong>always</strong> have a chance of getting a hash collision regardless of what hashing algorithm you're using. However, in the case of pretty much anything equal to or greater than SHA256, the chance is so vanishingly small that is is not worth worrying about. Your time is better spent worrying about the chances of a bus running over your server in the next second.


uuid can generate duplicates but the chance is very very very small.

Security::hash of cakePHP looks like the hash function of PHP.

If you use it with sha512 it should be pretty good.


  • Update All Rows in DataBase with a hash value [closed]
  • What is the better pratice: duplicate code or use goto statement? [closed]
  • Is it possible to change the Hashing algorithm in django_auth?
  • How to create a for loop in R? [duplicate]
  • System.Data.SQLite BadImageFormatException with NHibernate, works finewhen standalone
  • Including an Angular2 application to Asp.Net Webforms Page
  • Error compiling OpenSSL for Win32
  • Subclass HashSet so that it always uses a certain IEqualityComparer when used in another set
  • Determining signed state for HDF5 variables in NetCDF
  • Java set and contains
  • How to deal with xxx~HEAD after git merge?
  • UUID into unsigned int
  • Determine if a mesh is inside another mesh in threejs
  • Is there a greater chance to collide when comparing GUIDs based on a hash vs \"Guid.NewGuid()?
  • Excel not inserting leading zero
  • Sed: Using a,c or i in a one-liner
  • How do you keep a running instance for Google App Engine
  • Regex for nested values
  • How gzip file gets stored in HDFS
  • Scanner nextInt() and hasNextInt() problems
  • C# - Most efficient way to iterate through multiple arrays/list
  • netsh acl setting (need alternative method - registry settings?)
  • ThreadStatic in asynchronous ASP.NET Web API
  • Django model inheritance, filtering models
  • Why use database factory in asp.net mvc?
  • OOP Javascript - Is “get property” method necessary?
  • Remove final comma from string in vb.net
  • Time complexity of a program which involves multiple variables
  • one Local Olampyad Questions on Informatic in 2011
  • Illegal mix of collations for operation for date/time comparison
  • Splitting given String into two variables - php
  • Deserializing XML into class C#
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • 0x202A in filename: Why?
  • WPF Applying a trigger on binding failure
  • python regex in pyparsing
  • How do you join a server to an Active Directory (domain)?
  • How does Linux kernel interrupt the application?
  • python draw pie shapes with colour filled
  • How to Embed XSL into XML