~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/md5/md5.cc

  • Committer: Brian Aker
  • Date: 2010-03-31 19:14:14 UTC
  • Revision ID: brian@gaz-20100331191414-9yv44mmpvf0tb7l1
Updated to use show schemas specific table.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
 
69
69
  null_value= false;
70
70
 
 
71
  unsigned char digest[16];
71
72
  str->set_charset(&my_charset_bin);
72
73
 
73
 
  gcry_md_hd_t md5_context;
74
 
  gcry_md_open(&md5_context, GCRY_MD_MD5, 0);
75
 
  gcry_md_write(md5_context, sptr->ptr(), sptr->length());  
76
 
  unsigned char *digest= gcry_md_read(md5_context, 0);
 
74
  gcry_md_hash_buffer(GCRY_MD_MD5, digest, sptr->ptr(), sptr->length());
77
75
 
78
76
  snprintf((char *) str->ptr(), 33,
79
77
    "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
83
81
    digest[12], digest[13], digest[14], digest[15]);
84
82
  str->length((uint32_t) 32);
85
83
 
86
 
  gcry_md_close(md5_context);
87
 
 
88
84
  return str;
89
85
}
90
86
 
91
87
 
92
88
plugin::Create_function<Md5Function> *md5udf= NULL;
93
89
 
94
 
static int initialize(module::Context &context)
 
90
static int initialize(plugin::Context &context)
95
91
{
96
 
  /* Initialize libgcrypt */
97
 
  if (not gcry_check_version(GCRYPT_VERSION))
98
 
  {
99
 
    errmsg_printf(ERRMSG_LVL_ERROR, _("libgcrypt library version mismatch\n"));
100
 
    return 1;
101
 
  }
102
 
  /* Disable secure memory.  */
103
 
  gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
104
 
 
105
 
  /* Tell Libgcrypt that initialization has completed. */
106
 
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
107
 
 
108
92
  md5udf= new plugin::Create_function<Md5Function>("md5");
109
93
  context.add(md5udf);
110
94
  return 0;