<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: hashing code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 07 Sep 2008 07:19:05 GMT</pubDate>
    <description>DZone Snippets: hashing code</description>
    <item>
      <title>User friendly hashes with only upper case characters and digits</title>
      <link>http://snippets.dzone.com/posts/show/263</link>
      <description>I need a fast, user friendly hash. This means I want it to be only capital letters and digits. No symbols that people can't pronounce, and no mixed case to be misunderstood on the phone, etc. Use a hashing method like MD5 or SHA1 first, and then apply this..&lt;br /&gt;&lt;br /&gt;Ruby&lt;br /&gt;&lt;code&gt;newhash = oldhash.scan(/./).map{|t1| t2 = t1[0] % 36; t2 &lt; 26 ? (t2+65).chr : (t2+22).chr }.join&lt;/code&gt;&lt;br /&gt;Perl&lt;br /&gt;&lt;code&gt;$newhash = join "", map { $t1 = ord($_) % 36; $t1 &lt; 26 ? chr($t1+65) : chr($t1+22) } split(//, $oldhash);&lt;/code&gt;&lt;br /&gt;This turns any hash into only using [A-Z0-9]. Even a 8 character hash/key using [A-Z0-9] results in 2,821,109,907,456 combinations ;-)</description>
      <pubDate>Sun, 08 May 2005 00:11:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/263</guid>
      <author>peter (Peter Cooperx)</author>
    </item>
  </channel>
</rss>
