Module: Colppy::Digest
Constant Summary collapse
- MD5_DIGEST =
OpenSSL::Digest.new("md5").freeze
Class Method Summary collapse
Class Method Details
.md5(string) ⇒ Object
7 8 9 10 |
# File 'lib/colppy/digest.rb', line 7 def md5(string) return string if valid_md5?(string) MD5_DIGEST.hexdigest(string) end |
.valid_md5?(string) ⇒ Boolean
12 13 14 |
# File 'lib/colppy/digest.rb', line 12 def valid_md5?(string) !!(%r{^[a-f0-9]{32}$}i =~ string) end |