1 -- source include/have_ssl.inc
4 drop table if exists t1;
7 create table t1 (x blob);
8 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','The quick red fox jumped over the lazy brown dog'));
9 insert into t1 values (des_encrypt('a','The quick red fox jumped over the lazy brown dog'));
10 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','a'));
11 insert into t1 values (des_encrypt('ab','The quick red fox jumped over the lazy brown dog'));
12 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','ab'));
13 insert into t1 values (des_encrypt('abc','The quick red fox jumped over the lazy brown dog'));
14 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abc'));
15 insert into t1 values (des_encrypt('abcd','The quick red fox jumped over the lazy brown dog'));
16 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abcd'));
17 insert into t1 values (des_encrypt('abcde','The quick red fox jumped over the lazy brown dog'));
18 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abcde'));
19 insert into t1 values (des_encrypt('abcdef','The quick red fox jumped over the lazy brown dog'));
20 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abcdef'));
21 insert into t1 values (des_encrypt('abcdefg','The quick red fox jumped over the lazy brown dog'));
22 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abcdefg'));
23 insert into t1 values (des_encrypt('abcdefgh','The quick red fox jumped over the lazy brown dog'));
24 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abcdefgh'));
25 insert into t1 values (des_encrypt('abcdefghi','The quick red fox jumped over the lazy brown dog'));
26 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abcdefghi'));
27 insert into t1 values (des_encrypt('abcdefghij','The quick red fox jumped over the lazy brown dog'));
28 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abcdefghij'));
29 insert into t1 values (des_encrypt('abcdefghijk','The quick red fox jumped over the lazy brown dog'));
30 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','abcdefghijk'));
31 insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','sabakala'));
32 insert into t1 values (des_encrypt('quick red fox jumped over the lazy brown dog','sabakala'));
33 insert into t1 values (des_encrypt('red fox jumped over the lazy brown dog','sabakala'));
34 insert into t1 values (des_encrypt('fox jumped over the lazy brown dog','sabakala'));
35 insert into t1 values (des_encrypt('jumped over the lazy brown dog','sabakala'));
36 insert into t1 values (des_encrypt('over the lazy brown dog','sabakala'));
37 insert into t1 values (des_encrypt('the lazy brown dog','sabakala'));
38 insert into t1 values (des_encrypt('lazy brown dog','sabakala'));
39 insert into t1 values (des_encrypt('brown dog','sabakala'));
40 insert into t1 values (des_encrypt('dog','sabakala'));
41 insert into t1 values (des_encrypt('dog!','sabakala'));
42 insert into t1 values (des_encrypt('dog!!','sabakala'));
43 insert into t1 values (des_encrypt('dog!!!','sabakala'));
44 insert into t1 values (des_encrypt('dog!!!!','sabakala'));
45 insert into t1 values (des_encrypt('dog!!!!!','sabakala'));
46 insert into t1 values (des_encrypt('jumped over the lazy brown dog','sabakala'));
47 insert into t1 values (des_encrypt('jumped over the lazy brown dog','sabakala'));
48 select hex(x), hex(des_decrypt(x,'sabakala')) from t1;
49 select des_decrypt(x,'sabakala') as s from t1 having s like '%dog%';
55 select hex(des_encrypt("hello")),des_decrypt(des_encrypt("hello"));
56 select des_decrypt(des_encrypt("hello",4));
57 select des_decrypt(des_encrypt("hello",'test'),'test');
58 select hex(des_encrypt("hello")),hex(des_encrypt("hello",5)),hex(des_encrypt("hello",'default_password'));
59 select des_decrypt(des_encrypt("hello"),'default_password');
60 select des_decrypt(des_encrypt("hello",4),'password4');
62 # Test use of invalid parameters
63 select des_encrypt("hello",10);
64 select des_encrypt(NULL);
65 select des_encrypt(NULL, 10);
66 select des_encrypt(NULL, NULL);
67 select des_encrypt(10, NULL);
68 select des_encrypt("hello", NULL);
70 select des_decrypt("hello",10);
71 select des_decrypt(NULL);
72 select des_decrypt(NULL, 10);
73 select des_decrypt(NULL, NULL);
74 select des_decrypt(10, NULL);
75 select des_decrypt("hello", NULL);
79 SET @a=des_decrypt(des_encrypt("hello"));
81 select @a = des_decrypt(des_encrypt("hello"));
83 # Test usage of wrong password
85 select hex(des_decrypt(des_encrypt("hello",4),'password2'));
86 select hex(des_decrypt(des_encrypt("hello","hidden")));
88 explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden"));
93 # Bug#44365 valgrind warnings with encrypt() function
96 drop table if exists t1;
98 create table t1 (f1 smallint(6) default null, f2 mediumtext character set utf8)
99 engine=myisam default charset=latin1;
100 insert into t1 values (null,'contraction\'s');
101 insert into t1 values (-15818,'requirement\'s');
103 select encrypt(f1,f2) as a from t1,(select encrypt(f1,f2) as b from t1) a;