mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-25 08:22:18 +00:00
Fixed hex representation of KademliaID
This commit is contained in:
parent
d72e0065e1
commit
4b617c249a
@ -20,7 +20,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
def room_version = "2.1.0-alpha04"
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
@ -30,4 +29,5 @@ dependencies {
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
annotationProcessor "androidx.room:room-compiler:$room_version"
|
||||
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.Random;
|
||||
import io.github.chronosx88.influence.kademlia.message.Streamable;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
public class KademliaId implements Streamable, Serializable
|
||||
{
|
||||
@ -28,7 +29,7 @@ public class KademliaId implements Streamable, Serializable
|
||||
*/
|
||||
public KademliaId(String data)
|
||||
{
|
||||
keyBytes = data.getBytes();
|
||||
keyBytes = DatatypeConverter.parseHexBinary(data);
|
||||
if (keyBytes.length != ID_LENGTH / 8)
|
||||
{
|
||||
throw new IllegalArgumentException("Specified Data need to be " + (ID_LENGTH / 8) + " characters long.");
|
||||
@ -249,9 +250,7 @@ public class KademliaId implements Streamable, Serializable
|
||||
|
||||
public String hexRepresentation()
|
||||
{
|
||||
/* Returns the hex format of this NodeId */
|
||||
BigInteger bi = new BigInteger(1, this.keyBytes);
|
||||
return String.format("%0" + (this.keyBytes.length << 1) + "X", bi);
|
||||
return DatatypeConverter.printHexBinary(this.keyBytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user