Code:
client.java:12: unreported exception java.io.UnsupportedEncodingException; must
be caught or declared to be thrown
in.getBytes( "8859_1"/* encoding */ );
^
client.java:13: unreported exception java.security.NoSuchAlgorithmException; mus
t be caught or declared to be thrown
MessageDigest md = MessageDigest.getInstance( "SHA" );
^
Note: stream.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
Used "C:\Program Files\Java\jdk1.6.0_11\bin\javac.exe" to compile your files!
Press any key to continue . . .
ok i got that error when i added this
Code:
public String SMF_MD5(String in) {
byte[] theTextToDigestAsBytes =
in.getBytes( "8859_1"/* encoding */ );
MessageDigest md = MessageDigest.getInstance( "SHA" );
md.update( theTextToDigestAsBytes );
byte[] digest = md.digest();
// will print SHA
// should be 20 bytes, 160 bits long
// dump out the hash
for ( byte b : digest )
{
return Integer.toHexString( b & 0xff );
}
return "";
}
public boolean Load(String Password) {
try{
Statement statement = server.conn.createStatement();
ResultSet group = statement.executeQuery("SELECT * FROM smf_ WHERE username = '"+playerName+"'");
while(group.next()) {
String RealPass = group.getString("password");
String tempName = playerName.toLowerCase();
String toEncode = tempName+Password;
String EnteredPass_Hash = SMF_MD5(toEncode);
if(RealPass.equals(EnteredPass_Hash)) {
return true;
} else {
statement.close();
return false;
}
}
} catch (Exception sqlEx){
try{
server.conn.close();
server.createConnection();
} catch (Exception sqlEx2){}
//System.err.println(sqlEx);
return false;
}
return false;
}
from the tut here