File: testDigest.rb

package info (click to toggle)
jruby 1.5.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 46,252 kB
  • ctags: 72,039
  • sloc: ruby: 398,155; java: 169,482; yacc: 3,782; xml: 2,469; ansic: 415; sh: 279; makefile: 78; tcl: 40
file content (18 lines) | stat: -rw-r--r-- 604 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'test/minirunit'
test_check "Test Digest module:"

require "digest/md5"
require "digest/sha1"

a = Digest::MD5.new
a << "f"
a.update "o"
a << "o"

test_equal("acbd18db4cc2f85cedef654fccc4a4d8", a.hexdigest)
test_equal("acbd18db4cc2f85cedef654fccc4a4d8", a.to_s)
test_equal("#<Digest::MD5: acbd18db4cc2f85cedef654fccc4a4d8>", a.inspect)

test_equal("acbd18db4cc2f85cedef654fccc4a4d8",  Digest::MD5.hexdigest("foo"))
test_equal("\254\275\030\333L\302\370\\\355\357eO\314\304\244\330", Digest::MD5.digest("foo"))
test_equal("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33", Digest::SHA1.hexdigest("foo"))