Popular recipes tagged "hash" but not "borg"http://code.activestate.com/recipes/tags/hash-borg/2015-04-16T12:11:34-07:00ActiveState Code RecipesHashing Nonhashable / Mutable Objects (Python) 2015-04-16T12:11:34-07:00Max Morozhttp://code.activestate.com/recipes/users/4168744/http://code.activestate.com/recipes/579047-hashing-nonhashable-mutable-objects/ <p style="color: grey"> Python recipe 579047 by <a href="/recipes/users/4168744/">Max Moroz</a> (<a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python3/">python3</a>). Revision 2. </p> <p>This class is intended as a wrapper for non-hashable objects (such as lists, dictionaries, etc.) in situations where the object is known to be immutable. Example: memoization of function arguments.</p> <p>Feedback much appreciated, I will update to reflect any comments.</p> Hash collision probability / Birthday problem (Python) 2012-12-21T09:32:54-08:00Sander Evershttp://code.activestate.com/recipes/users/4173111/http://code.activestate.com/recipes/578387-hash-collision-probability-birthday-problem/ <p style="color: grey"> Python recipe 578387 by <a href="/recipes/users/4173111/">Sander Evers</a> (<a href="/recipes/tags/birthday/">birthday</a>, <a href="/recipes/tags/collision/">collision</a>, <a href="/recipes/tags/hash/">hash</a>). </p> <p>Calculates the probability that, when making <em>k</em> random selections out of <em>n</em> possibilities, at least two of the selections are the same. See: <a href="http://en.wikipedia.org/wiki/Birthday_problem" rel="nofollow">http://en.wikipedia.org/wiki/Birthday_problem</a></p> <p>What is the probability that (at least) two people in a class of 30 share their birthday?</p> <pre class="prettyprint"><code>&gt;&gt;&gt; collide(30,365) 0.7063162427192688 </code></pre> <p>What is the probability that ORA_HASH generates the same hash when hashing 25000 values?</p> <pre class="prettyprint"><code>&gt;&gt;&gt; collide(25000,int(4.3e9)) 0.07009388771353198 </code></pre> bubblebabble (Python) 2012-11-03T09:28:41-07:00Space Hobohttp://code.activestate.com/recipes/users/4184146/http://code.activestate.com/recipes/578319-bubblebabble/ <p style="color: grey"> Python recipe 578319 by <a href="/recipes/users/4184146/">Space Hobo</a> (<a href="/recipes/tags/babble/">babble</a>, <a href="/recipes/tags/bubble/">bubble</a>, <a href="/recipes/tags/digest/">digest</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/human/">human</a>, <a href="/recipes/tags/readable/">readable</a>). </p> <p>This module provides a bubblebabble function, which computes a (somewhat more) human readable format for message digests.</p> Checking hashes of files (Ruby) 2012-11-19T08:45:51-08:00greg zakharovhttp://code.activestate.com/recipes/users/4184115/http://code.activestate.com/recipes/578339-checking-hashes-of-files/ <p style="color: grey"> Ruby recipe 578339 by <a href="/recipes/users/4184115/">greg zakharov</a> (<a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/ironruby/">ironruby</a>, <a href="/recipes/tags/md5/">md5</a>, <a href="/recipes/tags/ripemd160/">ripemd160</a>, <a href="/recipes/tags/sha1/">sha1</a>, <a href="/recipes/tags/sha256/">sha256</a>, <a href="/recipes/tags/sha384/">sha384</a>, <a href="/recipes/tags/sha512/">sha512</a>). </p> <p>There is HashAlgorithm class in System.Security.Cryptography namespace which is stored into mscorlib, a core assembly of .NET Framework. So...</p> Getting the SHA-1 (or MD5) hash of a directory (Python) 2009-12-06T19:02:40-08:00Stephen Akikihttp://code.activestate.com/recipes/users/4172143/http://code.activestate.com/recipes/576973-getting-the-sha-1-or-md5-hash-of-a-directory/ <p style="color: grey"> Python recipe 576973 by <a href="/recipes/users/4172143/">Stephen Akiki</a> (<a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/getting/">getting</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/md5/">md5</a>, <a href="/recipes/tags/sha_1/">sha_1</a>, <a href="/recipes/tags/the/">the</a>). Revision 4. </p> <h5><a href="http://akiscode.com/articles/sha-1directoryhash.shtml" rel="nofollow">http://akiscode.com/articles/sha-1directoryhash.shtml</a></h5> <p>By definition a cryptographic hash is, "a deterministic procedure that takes an arbitrary block of data and returns a fixed-size bit string, the (cryptographic) hash value, such that an accidental or intentional change to the data will change the hash value". </p> <p>Usually these hashes are used on files to "fingerprint" them, but in order to do the same to a directory you have to do something like this: </p> Generate a salt (PHP) 2012-07-10T19:52:17-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/576894-generate-a-salt/ <p style="color: grey"> PHP recipe 576894 by <a href="/recipes/users/4171602/">Xavier L.</a> (<a href="/recipes/tags/crypt/">crypt</a>, <a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/pass/">pass</a>, <a href="/recipes/tags/password/">password</a>, <a href="/recipes/tags/salt/">salt</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/string/">string</a>). Revision 6. </p> <p>This function will generate a salt for use with passwords ranging using characters in range a to z, A to Z, 0 to 9 and !@#$%&amp;<em>?. The characters are sorted in a random value and can appear more than one time in the string. This way, this function is more powerful than the *shuffle()</em> function. This means that the salt could also be longer than the character list.</p> Hash text simply (PHP) 2012-04-30T21:43:00-07:00Xavier L.http://code.activestate.com/recipes/users/4171602/http://code.activestate.com/recipes/576893-hash-text-simply/ <p style="color: grey"> PHP recipe 576893 by <a href="/recipes/users/4171602/">Xavier L.</a> (<a href="/recipes/tags/crypt/">crypt</a>, <a href="/recipes/tags/extensible/">extensible</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/php/">php</a>, <a href="/recipes/tags/secure/">secure</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/simple/">simple</a>). Revision 5. </p> <p>This is a simply and extensible script that can be used to rapidly has any amount of text using PHP's hash() built-in function.</p> <p>It recognizes when the page is loaded for the first time and displays a form with options. Afterward, it display the selected hash(es), with a link at the bottom to start again.</p> Create SHA Hashes of a Directory (Python) 2009-04-14T08:10:26-07:00andrew.canithttp://code.activestate.com/recipes/users/4169843/http://code.activestate.com/recipes/576716-create-sha-hashes-of-a-directory/ <p style="color: grey"> Python recipe 576716 by <a href="/recipes/users/4169843/">andrew.canit</a> (<a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/sha/">sha</a>). Revision 2. </p> <p>Walk through a Directory creating SHA Hashes of each file path</p>