summaryrefslogtreecommitdiff
path: root/ext/digest/digest.txt
blob: 4969a9da9032119341673fcb9415a77c38c8ddd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
.\" digest.txt -  -*- Indented-Text -*- created at: Fri May 25 08:13:50 JST 2001
$RoughId: digest.txt,v 1.9 2001/07/13 19:46:51 knu Exp $
$Id: digest.txt,v 1.1 2001/07/13 20:06:13 knu Exp $

** MD5(Class)

A class to implement the MD5 Message-Digest Algorithm by RSA Data
Security, Inc., described in RFC1321.

Superclass: Digest::Base

require 'digest/md5'

** SHA1(Class)

A class to implement the SHA-1 Secure Hash Algorithm by NIST (the US'
National Institute of Standards and Technology), described in FIPS PUB
180-1.

Superclass: Digest::Base

require 'digest/sha1'

** SHA256(Class)
** SHA384(Class)
** SHA512(Class)

Classes to implement the SHA-256/384/512 Secure Hash Algorithm(s) by
NIST (the US' National Institute of Standards and Technology),
described in FIPS PUB 180-2.

Superclass: Digest::Base

require 'digest/sha2'

** RMD160(Class)

A class to implement the RIPEMD-160 cryptographic hash function,
designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel.

Superclass: Digest::Base

require 'digest/rmd160'


Those above classes provide a common interface as shown below.


Class Methods:

   new([str])

	Creates a new digest object.  If a string argument is given,
	it is added to the object. (see update.)

   digest(str)

	Immediately calculates and return the hash of the given
	strings as a string.  Equivalent to new(str).digest.

   hexdigest(str)

	Immediately calculates and return the hash of the given
	strings as a string of hexadecimal digits.  Equivalent to
	new(str).hexdigest.

Methods:

   clone

	Creates a copy of the digest object.

   digest

	Returns the hash of the added strings as a string of 16 bytes
	for MD5, 20 bytes for SHA1 and RMD160, 32 bytes for SHA256, 48
	bytes for SHA384, and 64 bytes for SHA512.

   hexdigest
   to_s

	Returns the hash of the added strings as a string of 32
	hexadecimal digits for MD5, 40 hexadecimal digits for SHA1 and
	RMD160, 64 hexadecimal digits for SHA256, 96 hexadecimal
	digits for SHA384, and 128 hexadecimal digits for SHA512.
	This method is equal to:

	def hexdigest
	  digest.unpack("H*")[0]
	end

   update(str)
   << str

	Appends the string str to the digest object.  Repeated calls
	are equivalent to a single call with the concatenation of all
	the arguments, i.e. m.update(a); m.update(b) is equivalent to
	m.update(a + b) and m << a << b is equivalent to m << a + b.

   == md

	Checks if the object is equal to the given digest object.

   == str

	Regards the value as either a digest value or a hexdigest
	value (depending on the length) and checks if the object is
	equal to the given string.

-------------------------------------------------------
Local variables:
fill-column: 70
end: