mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* ext/digest/*: [DOC] Fix several typos and broken http links.
Improved examples for Digest overview and fixed a broken example in Digest::HMAC overview. This patch also adds a description of Digest::SHA256.bubblebabble to the Digest overview. Patched by @stomar [Bug #9027] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									1dd8260dfa
								
							
						
					
					
						commit
						4c1e390fa8
					
				
					 4 changed files with 47 additions and 21 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,12 @@
 | 
			
		|||
Wed Nov 13 19:02:05 2013  Zachary Scott  <e@zzak.io>
 | 
			
		||||
 | 
			
		||||
	* ext/digest/*: [DOC] Fix several typos and broken http links.
 | 
			
		||||
	  Improved examples for Digest overview and fixed a broken example in
 | 
			
		||||
	  Digest::HMAC overview. This patch also adds a description of
 | 
			
		||||
	  Digest::SHA256.bubblebabble to the Digest overview.
 | 
			
		||||
 | 
			
		||||
	  Patched by @stomar [Bug #9027]
 | 
			
		||||
 | 
			
		||||
Wed Nov 13 18:32:12 2013  Zachary Scott  <e@zzak.io>
 | 
			
		||||
 | 
			
		||||
	* ext/openssl/ossl_config.c: [DOC] Document the following:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,37 +32,58 @@ RUBY_EXTERN void Init_digest_base(void);
 | 
			
		|||
 *
 | 
			
		||||
 * You may want to look at OpenSSL::Digest as it supports more algorithms.
 | 
			
		||||
 *
 | 
			
		||||
 * A cryptographic hash function is a procedure that takes data and return a
 | 
			
		||||
 * fixed bit string : the hash value, also known as _digest_. Hash functions
 | 
			
		||||
 * A cryptographic hash function is a procedure that takes data and returns a
 | 
			
		||||
 * fixed bit string: the hash value, also known as _digest_. Hash functions
 | 
			
		||||
 * are also called one-way functions, it is easy to compute a digest from
 | 
			
		||||
 * a message, but it is infeasible to generate a message from a digest.
 | 
			
		||||
 *
 | 
			
		||||
 * == Example
 | 
			
		||||
 * == Examples
 | 
			
		||||
 *
 | 
			
		||||
 *   require 'digest'
 | 
			
		||||
 *
 | 
			
		||||
 *   # Compute a complete digest
 | 
			
		||||
 *   Digest::SHA256.digest 'message'       #=> "\xABS\n\x13\xE4Y..."
 | 
			
		||||
 *
 | 
			
		||||
 *   sha256 = Digest::SHA256.new
 | 
			
		||||
 *   digest = sha256.digest message
 | 
			
		||||
 *   sha256.digest 'message'               #=> "\xABS\n\x13\xE4Y..."
 | 
			
		||||
 *
 | 
			
		||||
 *   # Other encoding formats
 | 
			
		||||
 *   Digest::SHA256.hexdigest 'message'    #=> "ab530a13e459..."
 | 
			
		||||
 *   Digest::SHA256.base64digest 'message' #=> "q1MKE+RZFJgr..."
 | 
			
		||||
 *
 | 
			
		||||
 *   # Compute digest by chunks
 | 
			
		||||
 *   sha256 = Digest::SHA256.new
 | 
			
		||||
 *   sha256.update message1
 | 
			
		||||
 *   sha256 << message2 # << is an alias for update
 | 
			
		||||
 *   md5 = Digest::MD5.new
 | 
			
		||||
 *   md5.update 'message1'
 | 
			
		||||
 *   md5 << 'message2'                     # << is an alias for update
 | 
			
		||||
 *
 | 
			
		||||
 *   digest = sha256.digest
 | 
			
		||||
 *   md5.hexdigest                         #=> "94af09c09bb9..."
 | 
			
		||||
 *
 | 
			
		||||
 *   # Compute digest for a file
 | 
			
		||||
 *   sha256 = Digest::SHA256.file 'testfile'
 | 
			
		||||
 *   sha256.hexdigest
 | 
			
		||||
 *
 | 
			
		||||
 * Additionally digests can be encoded in "bubble babble" format as a sequence
 | 
			
		||||
 * of consonants and vowels which is more recognizable and comparable than a
 | 
			
		||||
 * hexadecimal digest.
 | 
			
		||||
 *
 | 
			
		||||
 *   require 'digest/bubblebabble'
 | 
			
		||||
 *
 | 
			
		||||
 *   Digest::SHA256.bubblebabble 'message' #=> "xopoh-fedac-fenyh-..."
 | 
			
		||||
 *
 | 
			
		||||
 * See the bubble babble specification at
 | 
			
		||||
 * http://web.mit.edu/kenta/www/one/bubblebabble/spec/jrtrjwzi/draft-huima-01.txt.
 | 
			
		||||
 *
 | 
			
		||||
 * == Digest algorithms
 | 
			
		||||
 *
 | 
			
		||||
 * Different digest algorithms (or hash functions) are available :
 | 
			
		||||
 * Different digest algorithms (or hash functions) are available:
 | 
			
		||||
 *
 | 
			
		||||
 * HMAC::
 | 
			
		||||
 *   See FIPS PUB 198 The Keyed-Hash Message Authentication Code (HMAC)
 | 
			
		||||
 *   See FIPS PUB 198 The Keyed-Hash Message Authentication Code (HMAC).
 | 
			
		||||
 * RIPEMD-160::
 | 
			
		||||
 *   (as Digest::RMD160) see
 | 
			
		||||
 *   http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
 | 
			
		||||
 *   As Digest::RMD160.
 | 
			
		||||
 *   See http://homes.esat.kuleuven.be/~bosselae/ripemd160.html.
 | 
			
		||||
 * SHA1::
 | 
			
		||||
 *   See FIPS 180 Secure Hash Standard
 | 
			
		||||
 *   See FIPS 180 Secure Hash Standard.
 | 
			
		||||
 * SHA2 family::
 | 
			
		||||
 *   See FIPS 180 Secure Hash Standard which defines the following algorithms:
 | 
			
		||||
 *   * SHA512
 | 
			
		||||
| 
						 | 
				
			
			@ -70,11 +91,7 @@ RUBY_EXTERN void Init_digest_base(void);
 | 
			
		|||
 *   * SHA256
 | 
			
		||||
 *
 | 
			
		||||
 * The latest versions of the FIPS publications can be found here:
 | 
			
		||||
 * http://csrc.nist.gov/publications/PubsFIPS.html
 | 
			
		||||
 *
 | 
			
		||||
 * Additionally Digest::BubbleBabble encodes a digest as a sequence of
 | 
			
		||||
 * consonants and vowels which is more recognizable and comparable than a
 | 
			
		||||
 * hexadecimal digest.  See http://en.wikipedia.org/wiki/Bubblebabble
 | 
			
		||||
 * http://csrc.nist.gov/publications/PubsFIPS.html.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ module Digest
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  class ::Digest::Class
 | 
			
		||||
    # creates a digest object and reads a given file, _name_.
 | 
			
		||||
    # Creates a digest object and reads a given file, _name_.
 | 
			
		||||
    # Optional arguments are passed to the constructor of the digest
 | 
			
		||||
    # class.
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ module Digest
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  module Instance
 | 
			
		||||
    # updates the digest with the contents of a given file _name_ and
 | 
			
		||||
    # Updates the digest with the contents of a given file _name_ and
 | 
			
		||||
    # returns self.
 | 
			
		||||
    def file(name)
 | 
			
		||||
      File.open(name, "rb") {|f|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ module Digest
 | 
			
		|||
  #     hmac.update(buf)
 | 
			
		||||
  #   end
 | 
			
		||||
  #
 | 
			
		||||
  #   puts hmac.bubblebabble
 | 
			
		||||
  #   puts hmac.hexdigest
 | 
			
		||||
  #
 | 
			
		||||
  class HMAC < Digest::Class
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue