怎么把user表的pwd字段32位MD5加密啊

oooooooooooooooofuck 2012-10-16 02:42:52
怎么把user表的userid从121到5000的数据的pwd字段32位MD5加密啊
表结构如下:
userid pwd
1 123456
2 654321
……
...全文
189 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
fw0124 2012-10-16
  • 打赏
  • 举报
回复
--把user表的定义发下
desc "user"
Billy 2012-10-16
  • 打赏
  • 举报
回复
写个函数:
create or replace function md5(pwd in varchar2)
return varchar2
is
rv varchar2(32);
begin
rv := Utl_Raw.Cast_To_Raw(sys.dbms_obfuscation_toolkit.md5(input_string => pwd));
return rv;
end;

然后:
update user set pwd=md5(pwd) where userid between 121 and 5000;

  • 打赏
  • 举报
回复
update user set pwd=dbms_obfuscation_toolkit.md5(INPUT_STRING=>pwd)
我就是复制你的代码然后就报错ORA-00907: missing right parenthesis啊
fw0124 2012-10-16
  • 打赏
  • 举报
回复
scott@ORA11GR2> create table "user"(userid int, pwd varchar2(100));

Table created.

scott@ORA11GR2> insert into "user" values(121, '123456');

1 row created.

scott@ORA11GR2> insert into "user" values(5000, '654321');

1 row created.

scott@ORA11GR2> insert into "user" values(7000, '65321');

1 row created.

scott@ORA11GR2> update "user" set pwd=dbms_obfuscation_toolkit.md5(INPUT_STRING=>pwd)
2 where userid between 121 and 5000;

2 rows updated.

scott@ORA11GR2>
  • 打赏
  • 举报
回复
ORA-00907: missing right parenthesis
fw0124 2012-10-16
  • 打赏
  • 举报
回复
--才发现原来有个函数可以调,那就一条语句就行了
update "user" set pwd=dbms_obfuscation_toolkit.md5(INPUT_STRING=>pwd) where userid between 121 and 5000;
  • 打赏
  • 举报
回复
我这个表该怎么写啊
  • 打赏
  • 举报
回复
我晕,没看懂
fw0124 2012-10-16
  • 打赏
  • 举报
回复
--用dbms_obfuscation_toolkit就可以了。
declare
chksum varchar2(100);
begin
dbms_obfuscation_toolkit.md5(input_string=>'oracle', checksum_string=>chksum);
dbms_output.put_line(chksum);
end;

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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