2
嘿家伙在这里我有一个问题..在我的Java应用程序中有一个登录表单。在那里有一个选项“忘记密码..?”我想从那发送用户的密码..在这种情况下,用户的电子邮件地址标识用户名give..no that.But问题是密码加密..我怎么能得到那些密码以默认格式发送。我的登录名TABEL是登录和3场未私服,类型..我的邮件发送代码如下(admin或限制)..通过电子邮件发送密码
try{
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com"); // for gmail use smtp.gmail.com
props.put("mail.smtp.auth", "true");
props.put("mail.debug", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("[email protected]", "password");
}
});
mailSession.setDebug(true); // Enable the debug mode
Message msg = new MimeMessage(mailSession);
//--[ Set the FROM, TO, DATE and SUBJECT fields
msg.setFrom(new InternetAddress("[email protected]"));
msg.setRecipients( Message.RecipientType.TO,InternetAddress.parse("[email protected]"));
msg.setSentDate(new Date(232323));
msg.setSubject("Hello World!");
//--[ Create the body of the mail
msg.setText("Hello from my first e-mail sent with JavaMail");
//--[ Ask the Transport class to send our mail message
Transport.send(msg);
}catch(Exception E){
System.out.println("Oops something has gone pearshaped!");
System.out.println(E);
}
**不要以纯文本**存储密码。可逆加密(几乎)不会更好。你需要理解哈希的含义。 – SLaks
密码是加密密码还是哈希密码?加密密码需要使用正确的密钥进行解密。如果密码被散列,那么您将无法向用户发送他们的密码。相反,您必须要求用户创建一个新密码。 – Max
安全性**很难**。不要重新发明轮子。使用现有的,经过验证的认证软件包。 – SLaks