Class: String
Instance Method Summary collapse
-
#hash_djb2 ⇒ Object
DJB hash algorithm 2.
Instance Method Details
#hash_djb2 ⇒ Object
DJB hash algorithm 2. The default Ruby string hash is not stable across Ruby invocations (for security reasons).
26 27 28 29 30 31 32 |
# File 'lib/console/mux/color_formatter.rb', line 26 def hash_djb2 hash = 5381 each_codepoint do |c| hash = ((hash << 5) + hash) + c # equiv. hash * 33 + c? end hash end |