经过MD5加密过的数据怎么存到数据库……

jxbicestare 2003-10-15 05:57:36
某一字符串,经MD5加密后的字符串中有些字符mysql会不认或者转义掉(比如'\'),
要对此字符串做些什么处理?(C语言)
我看手册中的C API 中mysql_escape_string()函数是关于特殊字符转义的,但用了还是没效果。请大虾帮帮忙……
...全文
289 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wj81112 2003-10-16
  • 打赏
  • 举报
回复
请问jxbicestare(香波) ,你这里用的md5加密算法是mysql里面的么?
jxbicestare 2003-10-16
  • 打赏
  • 举报
回复
那C或VC中有没有标准的MD5加密算法的函数可用?
swotcoder 2003-10-16
  • 打赏
  • 举报
回复
下边是一个md5的C实现,你看一下吧!
/*
* Karn encryption
* Based on Phil Karn, sci.crypt, 13 Feb 1992
* See also his comments from sci.crypt, 23 Mar 1992.
* The method is a variant of that described in
* Zheng, Matsumoto and Imai, Crypto 89.
* See also, "A New Class of Cryptosystems Based on
* Interconnection Networks" by
* michaelp@terpsichore.informatic.rwth-aachen.de
*
* A method for turning a hash function, here MD5, into a fast
* secret-key encryption.
*
* This does triple hashing with nondistinct keys.
*/

typedef unsigned long UINT4;

/* Initial values for MD5 Transform hash function */
static UINT4 ihash[4] = {
0x67452301L, 0xefcdab89L, 0x98badcfeL, 0x10325476L };

/* MD5 hash function */
extern void Transform ();


/* Basic transform for Karn encryption. Take two 16-byte
half-buffers, two 48-byte keys (which must be distinct), and use
the MD5 Transform algorithm to produce two 16-byte output
half-buffers.

This is reversible: If we get out1 and out2 from in1, in2, key1, key2,
then we can get in2 and in1 from out2, out1, key1, key2.

in1, in2, out1, and out2 should point to 16-byte buffers.
By convention, in1 and in2 are two halves of a 32-byte input
buffer, and out1 and out2 are two halves of a 32-byte output
buffer.

key1 and key2 should point to 48-byte buffers with different contents.
*/
void
karn (out1, out2, in1, in2, key1, key2)
UINT4 *out1, *out2, *in1, *in2, *key1, *key2;
{
int i;
UINT4 buf[16];
UINT4 hash[4];
UINT4 temp[4];

bcopy (ihash, hash, sizeof(hash));
bcopy (in1, buf, 16);
bcopy (key1, buf+4, 48);
Transform (hash, buf);
for (i=0; i<4; ++i)
temp[i] = buf[i] = in2[i] ^ hash[i];
bcopy (ihash, hash, sizeof(hash));
bcopy (key2, buf+4, 48);
Transform (hash, buf);
for (i=0; i<4; ++i)
out2[i] = buf[i] = in1[i] ^ hash[i];
bcopy (ihash, hash, sizeof(hash));
bcopy (key1, buf+4, 48);
Transform (hash, buf);
for (i=0; i<4; ++i)
out1[i] = temp[i] ^ hash[i];
}
shuixin13 2003-10-15
  • 打赏
  • 举报
回复
呵呵,
是呀,检查你的 MD5 函数,
理论上不会出现要转义的字符的
swotcoder 2003-10-15
  • 打赏
  • 举报
回复
检查你的md5函数是否正确。

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧