<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/sha2.erl</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,7 +3,7 @@
 %%% Author  :  Sriram Krishnan&lt;mail@sriramkrishnan.com&gt;
 %%% Description : HMAC-SHA256 implementation. Implementation based on Wikipedia's
 %% pseudocode description of HMAC.  Relies on Steve Vinoski's SHA256 implementation
-%%% from http://steve.vinoski.net/code/sha256.erl
+%%% from http://steve.vinoski.net/code/sha2.erl
 %%%
 %%% Created : 30 Dec 2008
 %%%-------------------------------------------------------------------
@@ -30,7 +30,7 @@ digest(Key, Data, Hex) -&gt;
     
     %% If key is longer than block size, hash it to bring it below block size
     if
-	length(Key)&gt;BlockSize -&gt; ShortHashKey = array:from_list(sha256:digest(Key));
+	length(Key)&gt;BlockSize -&gt; ShortHashKey = array:from_list(unhex(sha2:digest256(Key),[]));
 	true-&gt; ShortHashKey = array:from_list(Key) 
     end,
     
@@ -50,13 +50,34 @@ digest(Key, Data, Hex) -&gt;
     OPadUpdated = array:map(PadUpdateFunc, OPad),
     IPadUpdated = array:map(PadUpdateFunc, IPad),
     
-    FinalTransform = OPadUpdated:to_list() ++ sha256:digest( IPadUpdated:to_list() ++ Data),
+    FinalTransform = OPadUpdated:to_list() ++ unhex(sha2:digest256( IPadUpdated:to_list() ++ Data),[]),
     
     if
-	Hex =:= true -&gt; sha256:hexdigest(FinalTransform);
-	Hex=:= false -&gt; sha256:digest( FinalTransform)
+	Hex =:= true -&gt; sha2:digest256(FinalTransform);
+	Hex=:= false -&gt; unhex(sha2:digest256( FinalTransform),[])
     end.
 
+%%
+%% Unhex functions adapted from ssl_debug and covered by the Erlang public license
+%%
+is_hex_digit(C) when C &gt;= $0, C =&lt; $9 -&gt; true;
+is_hex_digit(C) when C &gt;= $A, C =&lt; $F -&gt; true;
+is_hex_digit(C) when C &gt;= $a, C =&lt; $f -&gt; true;
+is_hex_digit(_) -&gt; false.
+
+unhex([], Acc) -&gt;
+    lists:reverse(Acc);
+unhex([_], Acc) -&gt;
+    unhex([], Acc);
+unhex([$  | Tl], Acc) -&gt;
+    unhex(Tl, Acc);
+unhex([D1, D2 | Tl], Acc) -&gt;
+    case {is_hex_digit(D1), is_hex_digit(D2)} of
+        {true, true} -&gt;
+            unhex(Tl, [erlang:list_to_integer([D1, D2], 16) | Acc]);
+        _ -&gt;
+            unhex([], Acc)
+    end.
 
 
 </diff>
      <filename>src/hmac256.erl</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>src/sha256.erl</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>1636da32e997bb0a67af9da9c9757d9e5d7c5606</id>
    </parent>
  </parents>
  <author>
    <name>Sriram Krishnan</name>
    <email>mail@sriramkrishnan.com</email>
  </author>
  <url>http://github.com/sriramk/winazureerl/commit/c7378900781a04447f878ca6a89a888a1bf8a6bb</url>
  <id>c7378900781a04447f878ca6a89a888a1bf8a6bb</id>
  <committed-date>2009-01-03T12:24:23-08:00</committed-date>
  <authored-date>2009-01-03T12:24:23-08:00</authored-date>
  <message>Fixed bug in hmac, updated to new version of SHA256 module</message>
  <tree>c50c2b77d9d291ba495014c0d09eabe7a960b857</tree>
  <committer>
    <name>Sriram Krishnan</name>
    <email>mail@sriramkrishnan.com</email>
  </committer>
</commit>
