rdoc_ext_digest.patch

Marcus Stollsteimer, 10/16/2013 08:35 PM

Download (4.21 KB)

View differences:

digest.c (Arbeitskopie)
32 32
 *
33 33
 * You may want to look at OpenSSL::Digest as it supports more algorithms.
34 34
 *
35
 * A cryptographic hash function is a procedure that takes data and return a
36
 * fixed bit string : the hash value, also known as _digest_. Hash functions
35
 * A cryptographic hash function is a procedure that takes data and returns a
36
 * fixed bit string: the hash value, also known as _digest_. Hash functions
37 37
 * are also called one-way functions, it is easy to compute a digest from
38 38
 * a message, but it is infeasible to generate a message from a digest.
39 39
 *
40
 * == Example
40
 * == Examples
41 41
 *
42 42
 *   require 'digest'
43 43
 *
44 44
 *   # Compute a complete digest
45
 *   Digest::SHA256.digest 'message'       #=> "\xABS\n\x13\xE4Y..."
46
 *
45 47
 *   sha256 = Digest::SHA256.new
46
 *   digest = sha256.digest message
48
 *   sha256.digest 'message'               #=> "\xABS\n\x13\xE4Y..."
47 49
 *
50
 *   # Other encoding formats
51
 *   Digest::SHA256.hexdigest 'message'    #=> "ab530a13e459..."
52
 *   Digest::SHA256.base64digest 'message' #=> "q1MKE+RZFJgr..."
53
 *
48 54
 *   # Compute digest by chunks
49
 *   sha256 = Digest::SHA256.new
50
 *   sha256.update message1
51
 *   sha256 << message2 # << is an alias for update
55
 *   md5 = Digest::MD5.new
56
 *   md5.update 'message1'
57
 *   md5 << 'message2'                     # << is an alias for update
52 58
 *
53
 *   digest = sha256.digest
59
 *   md5.hexdigest                         #=> "94af09c09bb9..."
54 60
 *
61
 *   # Compute digest for a file
62
 *   sha256 = Digest::SHA256.file 'testfile'
63
 *   sha256.hexdigest
64
 *
65
 * Additionally digests can be encoded in "bubble babble" format as a sequence
66
 * of consonants and vowels which is more recognizable and comparable than a
67
 * hexadecimal digest.
68
 *
69
 *   require 'digest/bubblebabble'
70
 *
71
 *   Digest::SHA256.bubblebabble 'message' #=> "xopoh-fedac-fenyh-..."
72
 *
73
 * See the bubble babble specification at
74
 * http://web.mit.edu/kenta/www/one/bubblebabble/spec/jrtrjwzi/draft-huima-01.txt.
75
 *
55 76
 * == Digest algorithms
56 77
 *
57
 * Different digest algorithms (or hash functions) are available :
78
 * Different digest algorithms (or hash functions) are available:
58 79
 *
59 80
 * HMAC::
60
 *   See FIPS PUB 198 The Keyed-Hash Message Authentication Code (HMAC)
81
 *   See FIPS PUB 198 The Keyed-Hash Message Authentication Code (HMAC).
61 82
 * RIPEMD-160::
62
 *   (as Digest::RMD160) see
63
 *   http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
83
 *   As Digest::RMD160.
84
 *   See http://homes.esat.kuleuven.be/~bosselae/ripemd160.html.
64 85
 * SHA1::
65
 *   See FIPS 180 Secure Hash Standard
86
 *   See FIPS 180 Secure Hash Standard.
66 87
 * SHA2 family::
67 88
 *   See FIPS 180 Secure Hash Standard which defines the following algorithms:
68 89
 *   * SHA512
......
70 91
 *   * SHA256
71 92
 *
72 93
 * The latest versions of the FIPS publications can be found here:
73
 * http://csrc.nist.gov/publications/PubsFIPS.html
74
 *
75
 * Additionally Digest::BubbleBabble encodes a digest as a sequence of
76
 * consonants and vowels which is more recognizable and comparable than a
77
 * hexadecimal digest.  See http://en.wikipedia.org/wiki/Bubblebabble
94
 * http://csrc.nist.gov/publications/PubsFIPS.html.
78 95
 */
79 96

  
80 97
static VALUE
lib/digest/hmac.rb (Arbeitskopie)
41 41
  #     hmac.update(buf)
42 42
  #   end
43 43
  #
44
  #   puts hmac.bubblebabble
44
  #   puts hmac.hexdigest
45 45
  #
46 46
  class HMAC < Digest::Class
47 47

  
lib/digest.rb (Arbeitskopie)
21 21
  end
22 22

  
23 23
  class ::Digest::Class
24
    # creates a digest object and reads a given file, _name_.
24
    # Creates a digest object and reads a given file, _name_.
25 25
    # Optional arguments are passed to the constructor of the digest
26 26
    # class.
27 27
    #
......
40 40
  end
41 41

  
42 42
  module Instance
43
    # updates the digest with the contents of a given file _name_ and
43
    # Updates the digest with the contents of a given file _name_ and
44 44
    # returns self.
45 45
    def file(name)
46 46
      File.open(name, "rb") {|f|