mirror of
https://github.com/moparisthebest/MoparClassic
synced 2024-11-12 04:05:12 -05:00
Removed hex-string lib and scala class, can do it in 1 line of pure java.
Also synchronized around md, since it can be accessed by multiple threads, right?
This commit is contained in:
parent
0bf23d8807
commit
57a8bdff9f
@ -12,7 +12,6 @@ import java.util.Random;
|
||||
import org.moparscape.msc.gs.connection.RSCPacket;
|
||||
import org.moparscape.msc.gs.core.GameEngine;
|
||||
import org.moparscape.msc.gs.model.Point;
|
||||
import org.moparscape.msc.gs.util.HexString;
|
||||
import org.moparscape.msc.gs.util.Logger;
|
||||
|
||||
public final class DataConversions {
|
||||
@ -258,9 +257,16 @@ public final class DataConversions {
|
||||
* returns the md5 hash of a string
|
||||
*/
|
||||
public static String md5(String s) {
|
||||
synchronized (md){
|
||||
md.reset();
|
||||
md.update(s.getBytes());
|
||||
return new HexString(md.digest()).toString();
|
||||
return toHex(md.digest());
|
||||
}
|
||||
}
|
||||
|
||||
public static String toHex(byte[] bytes) {
|
||||
// change below to lower or uppercase X to control case of output
|
||||
return String.format("%0" + (bytes.length << 1) + "x", new BigInteger(1, bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +0,0 @@
|
||||
package org.moparscape.msc.gs.util
|
||||
|
||||
class HexString(bytes: Array[Byte]) {
|
||||
lazy val string = bytes.map(0xFF & _).map { "%02x".format(_) }.foldLeft("") { _ + _ }
|
||||
|
||||
override def toString = string
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user