changed getHashString to use Base64

This commit is contained in:
Dave
2015-06-27 22:33:39 +02:00
parent ae4266b9ba
commit 01d15cc24d

View File

@@ -41,6 +41,8 @@ import javax.crypto.IllegalBlockSizeException;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
import sun.security.rsa.RSAPublicKeyImpl; import sun.security.rsa.RSAPublicKeyImpl;
import nodash.core.NoUtil; import nodash.core.NoUtil;
import nodash.exceptions.NoByteSetBadDecryptionException; import nodash.exceptions.NoByteSetBadDecryptionException;
@@ -53,8 +55,7 @@ public class NoUser implements Serializable {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private String randomized; private String randomized;
public int influences; private int influences;
public int actions;
private List<NoAction> outgoing = new ArrayList<NoAction>(); private List<NoAction> outgoing = new ArrayList<NoAction>();
@@ -79,7 +80,6 @@ public class NoUser implements Serializable {
this.publicKey = keyPair.getPublic(); this.publicKey = keyPair.getPublic();
this.privateKey = keyPair.getPrivate(); this.privateKey = keyPair.getPrivate();
this.influences = 0; this.influences = 0;
this.actions = 0;
this.touchRandomizer(); this.touchRandomizer();
} }
@@ -128,11 +128,7 @@ public class NoUser implements Serializable {
this.outgoing = temp; this.outgoing = temp;
} }
} }
public final String createHashString() {
return new String(this.createHash());
}
public final void consume(NoByteSet byteSet) throws NoByteSetBadDecryptionException { public final void consume(NoByteSet byteSet) throws NoByteSetBadDecryptionException {
try { try {
SecretKey secretKey = new SecretKeySpec(decryptRSA(byteSet.key), NoUtil.CIPHER_KEY_SPEC); SecretKey secretKey = new SecretKeySpec(decryptRSA(byteSet.key), NoUtil.CIPHER_KEY_SPEC);
@@ -156,7 +152,6 @@ public class NoUser implements Serializable {
public final void addAction(NoAction action) { public final void addAction(NoAction action) {
this.outgoing.add(action); this.outgoing.add(action);
this.actions++;
} }
public final List<NoAction> getNoActions() { public final List<NoAction> getNoActions() {
@@ -179,6 +174,10 @@ public class NoUser implements Serializable {
} }
} }
public int getInfluences() {
return influences;
}
private final byte[] decryptRSA(byte[] data) throws InvalidKeyException, private final byte[] decryptRSA(byte[] data) throws InvalidKeyException,
IllegalBlockSizeException, BadPaddingException { IllegalBlockSizeException, BadPaddingException {
return NoUtil.decryptRSA(data, this.privateKey); return NoUtil.decryptRSA(data, this.privateKey);
@@ -195,4 +194,8 @@ public class NoUser implements Serializable {
return noUser; return noUser;
} }
public String createHashString() {
return Base64.encodeBase64String(this.createHash());
}
} }