A fine-tuned implementation of the SHA256 hashing algorithm.

Dependents:   EntropySource Wallet_v1

Revision:
5:246096ab9e56
Parent:
4:81678751d669
Child:
6:c0ed1bf37651
--- a/SHA256.h	Mon Jun 20 11:06:11 2011 +0000
+++ b/SHA256.h	Mon Jun 20 11:11:10 2011 +0000
@@ -12,8 +12,17 @@
 ///
 /// This class has been heavily optimized for speed
 /// at a slight expense of code size.
+///
+/// Example usage:
+/// @code
+///   SHA256 hash;
+///   hash.append("The quick brown fox jumps over the lazy dog.");
+///   hash.finalize();
+///   std::cout << "Digest: " << hash.hexString() << std::endl;
+/// @endcode
 class SHA256 {
 public:
+
     //// Create a new instance, ready for appending
     SHA256() { reset(); }
     
@@ -26,22 +35,22 @@
     /// the function may read up to three bytes beyond
     /// the end of data.
     ///
-    /// @param data The bytes to be added.
-    /// @param size The number of bytes to read from data, but see the note.
+    /// @param data the bytes to be added.
+    /// @param size the number of bytes to read from data, but see the note.
     void append(const char* data, int size);
     
     /// Append a single byte
     ///
     /// Avoid this function if performance is important.
     ///
-    /// @param c The character to be appended.
+    /// @param c the character to be appended.
     void append(char c) { append(&c, 1); }
     
     /// Append a zero terminated string
     ///
     /// The terminating zero itself is not appended.
     ///
-    /// @param str The zero terminated string to be appended.
+    /// @param str the zero terminated string to be appended.
     void append(const char* str) { append(str, strlen(str)); }
     
     /// Append a std::string
@@ -57,12 +66,14 @@
     ///
     /// However, you can do this:
     /// @code
-    ///   SHA256 hash1, hash1and2;
-    ///   hash1.append("First part");
-    ///   hash1and2 = hash1;
-    ///   hash1.finalize();
-    ///   hash1and2.append("Second part");
-    ///   hash1and2.finalize();
+    ///   SHA256 A, AB;
+    ///   A.append("First part");
+    ///   AB = A;
+    ///   A.finalize();
+    ///   do_something(A.digest());
+    ///   AB.append("Second part");
+    ///   AB.finalize();
+    ///   do_something(AB.digest());
     /// @endcode
     void finalize();