diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2010-05-04 20:46:42 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2010-05-04 20:46:42 +0000 |
commit | d7d047f439880735377a4b8ea2ce2ef42921fff8 (patch) | |
tree | bfe733b55bcca11f6ccd30f9cea70e8800ca7b3c /src/couchdb/couch_util.erl | |
parent | 33b3524268195a0798993690b54cead286da28fb (diff) |
use crypto:md5 when available. thx fdmanana. Closes COUCHDB-757
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@941033 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_util.erl')
-rw-r--r-- | src/couchdb/couch_util.erl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index e685332d..af27636b 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -24,6 +24,7 @@ -export([verify/2,simple_call/2,shutdown_sync/1]). -export([compressible_att_type/1]). -export([get_value/2, get_value/3]). +-export([md5/1, md5_init/0, md5_update/2, md5_final/1]). -include("couch_db.hrl"). -include_lib("kernel/include/file.hrl"). @@ -412,3 +413,19 @@ compressible_att_type(MimeType) -> end, [T || T <- TypeExpList, T /= []] ). + +-spec md5(Data::iodata()) -> Digest::binary(). +md5(Data) -> + try crypto:md5(Data) catch error:_ -> erlang:md5(Data) end. + +-spec md5_init() -> Context::binary(). +md5_init() -> + try crypto:md5_init() catch error:_ -> erlang:md5_init() end. + +-spec md5_update(Context::binary(), Data::iodata()) -> NewContext::binary(). +md5_update(Ctx, D) -> + try crypto:md5_update(Ctx,D) catch error:_ -> erlang:md5_update(Ctx,D) end. + +-spec md5_final(Context::binary()) -> Digest::binary(). +md5_final(Ctx) -> + try crypto:md5_final(Ctx) catch error:_ -> erlang:md5_final(Ctx) end. |