drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
mysql_password.cc
1/* Copyright (C) 2010 Rackspace
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16#include <config.h>
17#include "mysql_password.h"
19#include <drizzled/util/convert.h>
20
21using namespace std;
22
23namespace drizzle_plugin {
24
25const char* MySQLPasswordName = "mysql_password";
26
27const char *MySQLPassword::func_name() const
28{
29 return MySQLPasswordName;
30}
31
32void MySQLPassword::fix_length_and_dec()
33{
34 max_length= args[0]->max_length;
35}
36
38{
39 return n == 1;
40}
41
43{
44 uint8_t hash_tmp1[SHA1_DIGEST_LENGTH];
45 uint8_t hash_tmp2[SHA1_DIGEST_LENGTH];
46
47 drizzled::String argument;
48 drizzled::do_sha1(*args[0]->val_str(&argument), hash_tmp1);
49 drizzled::do_sha1(data_ref(hash_tmp1, SHA1_DIGEST_LENGTH), hash_tmp2);
50
51 str->realloc(SHA1_DIGEST_LENGTH * 2);
52 drizzled::drizzled_string_to_hex(str->ptr(), reinterpret_cast<const char*>(hash_tmp2), SHA1_DIGEST_LENGTH);
53 str->length(SHA1_DIGEST_LENGTH * 2);
54
55 return str;
56}
57
58} /* namespace drizzle_plugin */
drizzled::String * val_str(drizzled::String *)
STL namespace.
SHA1 Declarations.