24 #include <drizzled/charset.h>
25 #include <drizzled/function/str/strfunc.h>
26 #include <drizzled/item/func.h>
27 #include <drizzled/plugin/function.h>
30 using namespace drizzled;
37 void fix_length_and_dec()
40 args[0]->collation.set(get_charset_by_csname(args[0]->collation.collation->csname, MY_CS_BINSORT), DERIVATION_COERCIBLE);
43 const char *func_name()
const
57 assert(fixed ==
true);
59 String *sptr= args[0]->val_str(str);
69 str->set_charset(&my_charset_bin);
71 gcry_md_hd_t md5_context;
72 gcry_md_open(&md5_context, GCRY_MD_MD5, 0);
73 gcry_md_write(md5_context, sptr->ptr(), sptr->length());
74 unsigned char *digest= gcry_md_read(md5_context, 0);
76 snprintf((
char *) str->ptr(), 33,
77 "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
78 digest[0], digest[1], digest[2], digest[3],
79 digest[4], digest[5], digest[6], digest[7],
80 digest[8], digest[9], digest[10], digest[11],
81 digest[12], digest[13], digest[14], digest[15]);
82 str->length((uint32_t) 32);
84 gcry_md_close(md5_context);
92 if (not gcry_check_version(GCRYPT_VERSION))
94 errmsg_printf(error::ERROR, _(
"libgcrypt library version mismatch"));
98 gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
101 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
103 context.add(
new plugin::Create_function<Md5Function>(
"md5"));
107 DRIZZLE_DECLARE_PLUGIN
119 DRIZZLE_DECLARE_PLUGIN_END;