[Facets] extending Digest::(MD5|SHA1|...) ?

12 views
Skip to first unread message

Guido De Rosa

unread,
Dec 1, 2010, 7:40:40 AM12/1/10
to facets-u...@rubyforge.org
How about extending Digest::MD5 and other message-digest algorithm
classes from the std library?

Some sugar like this would be really sweet:

Digest::MD5::LENGTH #=> 256
Digest::length(:MD5) #=> 256

Digest::MD5.digest('secret', :salt => 'mysalt')

The following would auto-generate a random salt of the optimal length
(which should be same as the hash , i.e. Digest::MD5::LENGTH bits)

Digest::MD5.dgest('secret', :salt => :auto)

Is there some interest in such feature? In such case, I would like to
write/contribute the code and I will report here about any progress.

Regards,
Guido

_______________________________________________
facets-universal mailing list
facets-u...@rubyforge.org
http://rubyforge.org/mailman/listinfo/facets-universal

Guido De Rosa

unread,
Dec 1, 2010, 6:05:18 PM12/1/10
to facets-u...@rubyforge.org
Some code is here:

http://snurl.com/1kavl2

It's basically a standard library extension from one of my own
projects, but all the logic might be easily extracted and put into
Facets...

You may write something like

Digest::SHA1.salted_base64digest('secret', 'salt')

or even

Digest::SHA1.salted_base64digest('secret')

with a salt auto-generated,

Trans

unread,
Feb 1, 2011, 9:29:36 AM2/1/11
to facets-u...@googlegroups.com, facets-u...@rubyforge.org
Cool. I'll have a look the code and see what I can add to Facets.

Reply all
Reply to author
Forward
0 new messages