怎么在用户注册的时候给密码加密并写进数据库?

wobuben521 2016-08-09 11:28:27
在用户注册的时候调用md5函数为什么写进数据库的密码还是明码?求一个MD5的算法
...全文
368 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
泡泡鱼_ 2016-08-09
  • 打赏
  • 举报
回复
基本上那是服务器端程序的事了
大叔爱洗澡 2016-08-09
  • 打赏
  • 举报
回复
请求的时候之前加密,写入数据库当然是密码的,下载jquery.md5.js插件
wobuben521 2016-08-09
  • 打赏
  • 举报
回复
怎么没人回复啊 ! 求大神!!!
wobuben521 2016-08-09
  • 打赏
  • 举报
回复
public class Md5Tool { public static String getMd5(String password){ String str = ""; if(password !=null && !password.equals("")){ try { MessageDigest md = MessageDigest.getInstance("MD5"); BASE64Encoder base = new BASE64Encoder(); //加密后的字符串 str = base.encode(md.digest(password.getBytes("utf-8"))); } catch (Exception e) { e.printStackTrace(); } } return str; } } 怎么解密啊
datangxiajun 2016-08-09
  • 打赏
  • 举报
回复
public class Enciypt { public static String createId(){ UUID uuid = UUID.randomUUID(); return uuid.toString(); } public static String md5(String str){ try{ //md5 MessageDigest md = MessageDigest.getInstance("MD5"); byte[] input = str.getBytes(); byte[] output = md.digest(input); System.out.println(output.length); //Base64 return Base64.encodeBase64String(output); }catch(Exception ex){ ex.printStackTrace(); return ""; } } public static void main(String[] args){ String id=Enciypt.createId(); System.out.println(id); System.out.println(md5("1234")); } }
wobuben521 2016-08-09
  • 打赏
  • 举报
回复
我先调用了md5把密码进行加密 在调用setpassword 进行加密后的设置我应该传什么参数进去

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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