зеркало из https://github.com/github/ruby.git
114 строки
2.6 KiB
Plaintext
114 строки
2.6 KiB
Plaintext
.\" 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$
|
|
|
|
** 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:
|