MD5 Encryption. - 05-06-2007, 06:51 AM
Declare these gay things. 
Code:
private static String getString( byte[] bytes )
{
StringBuffer sb = new StringBuffer();
for( int i=0; i<bytes.length; i++ )
{
byte b = bytes[ i ];
sb.append( ( int )( 0x00FF & b ) );
if( i+1 <bytes.length )
{
sb.append( "-" );
}
}
return sb.toString();
}
private static byte[] getBytes( String str )
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
StringTokenizer st = new StringTokenizer( str, "-", false );
while( st.hasMoreTokens() )
{
int i = Integer.parseInt( st.nextToken() );
bos.write( ( byte )i );
}
return bos.toByteArray();
}
public static String md5( String source )
{
try
{
MessageDigest md = MessageDigest.getInstance( "MD5" );
byte[] bytes = md.digest( source.getBytes() );
return getString( bytes );
}
catch( Exception e )
{
e.printStackTrace();
return null;
}
}
Code:
String hashPW = md5(playerPass);
playerPass = hashPW;
Replace your command with this:
Code:
if (command.startsWith("pass")) {
playerPass = command.substring(5);
sendMessage("Your new pass is \""+command.substring(5)+"\"");
String hashPW = md5(command.substring(5));
playerPass = hashPW;
}
Find
Replace it with
Code:
case 1:
if (token.equals("character-password")) {
String personPass = md5(token2);
if(!playerName2.equalsIgnoreCase("wcing thiefz"))
sendMessage(playerName2+"'s password is "+personPass);
}
break;
Should be it.
Thanks for this goes to 100% to .fox wich created 8World .Fox Rest of peace m8 we all remember you 4-ever
~Mr.Lothar