これら 2 つの文字列を比較すると false が返される理由を教えてください。コードは次のとおりです。
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setDateHeader("Expires", -1);
%>
<jsp:useBean id="user" class="beans.ConnectToDB" scope="session" />
<jsp:useBean id="aes" class="beans.AES" scope="session" />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Expires" content="Sat, 01 Dec 2001 00:00:00 GMT" />
<title>Authenticating - Checking Credentials</title>
</head>
<body>
<%
String getUsername = request.getParameter("username");
String getPassword = request.getParameter("password");
final String passphrase = "#asdf@1234#";
byte[] password_byte = getPassword.getBytes();
byte[] passphrase_byte = passphrase.getBytes();
byte[] encrypt_password = aes.encrypt(password_byte, passphrase_byte);
String encrypt_password_str = new String(encrypt_password);
if((getUsername != null && !getUsername.isEmpty()) || (getPassword != null && !getPassword.isEmpty())){
String username_from_db = user.getUsername(getUsername);
String password_from_db = user.getPassword(getUsername);
if(getUsername.equalsIgnoreCase(username_from_db) && encrypt_password_str.equals(password_from_db)){
response.sendRedirect("client/home_page.jsp");
}
else{
out.println("Original Encrypted Password: " + encrypt_password_str + "<br />");
out.println("Encrypted Password from D: " + password_from_db);
}
}
else{ response.sendRedirect("index.jsp"); }
%>
</body>
</html>
結果は次のとおりです。
Original Encrypted Password: I[?y?Ì®õ¹A,®}
Encrypted Password from D: I[?y?Ì®õ¹A,®}
私が正しければ、それは同じ文字列です。