Host, From, Caps, [SubNode | SubNodes]) ->
BinaryNode = node_to_binary(Caps#caps.node, SubNode),
IsValid = case Caps#caps.hash of
"md2" ->
Caps#caps.version == make_disco_hash(Els, md2);
"md5" ->
Caps#caps.version == make_disco_hash(Els, md5);
"sha-1" ->
concat_features(DiscoEls),
concat_info(DiscoEls)],
base64:encode_to_string(
if Algo == md2 ->
if Algo == md5 ->
sha:md2(Concat);
Algo == md5 ->
crypto:md5(Concat);
Algo == sha1 ->
crypto:sha(Concat);
-author('alexey@process-one.net').
-export([start/0, sha/1, sha1/1, sha224/1, sha256/1, sha384/1,
sha512/1, md2/1]).
sha512/1]).
-include("ejabberd.hrl").
sha512(Text) ->
erlang:port_control(?DRIVER, 512, Text).
md2(Text) ->
erlang:port_control(?DRIVER, 2, Text).
driver_path() ->
Suffix = case os:type() of
{win32, _} -> ".dll";
#include <erl_driver.h>
#include <openssl/sha.h>
#include <openssl/md2.h>
static ErlDrvData sha_drv_start(ErlDrvPort port, char *buf)
{
ErlDrvBinary *b = NULL;
switch (command) {
case 2:
rlen = MD2_DIGEST_LENGTH;
b = driver_alloc_binary(rlen);
if (b) MD2((unsigned char*)buf, len, (unsigned char*)b->orig_bytes);
break;
case 224:
rlen = SHA224_DIGEST_LENGTH;