posts - 431,  comments - 344,  trackbacks - 0
公告
 Don't Repeat Yourself
座右铭:you can lose your money, you can spent all of it, and if you work hard you get it all back. But if you waste your time, you're never gonna get it back.
公告本博客在此声明部分文章为转摘,只做资料收集使用。


微信: szhourui
QQ:109450684
Email
lsi.zhourui@gmail.com
<2008年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

留言簿(15)

随笔分类(1019)

文章分类(3)

文章档案(21)

收藏夹

Link

好友博客

最新随笔

搜索

  •  

积分与排名

  • 积分 - 855853
  • 排名 - 47

最新评论

阅读排行榜

根据Grails的命名规范, 到grails-app\utils 中创建一个名为 PasswordCodec Groovy 类(强调一下类名必需是 XXXCodec) , 代码如下:

import Java.security.MessageDigest
import sun.misc.BASE64Encoder
/**
 *
 * @author eric
 */
class PasswordCodec {
    static encode = {str ->
        MessageDigest md = MessageDigest.getInstance('SHA')
        md.update(str.getBytes('UTF-8'))
        return (new BASE64Encoder()).encode(md.digest())
    }
}
写好以后,使用如下:
user.save()user.password = user.password.encodeAsPassword()
user.save()

def user = User.findByUserNameAndPassword(params.userName, params.password.encodeAsPassword())


posted on 2008-07-28 23:00 周锐 阅读(627) 评论(0)  编辑  收藏 所属分类: Groovy&Grails

只有注册用户登录后才能发表评论。


网站导航: