~yujiri/libsufec-java

912e95173b1cec1b7d343f3ef37af1d4dede6493 — Yujiri a month ago 8693eb7
replace other timestamp types with java.util.Date
M src/main/java/jsufec/Connection.java => src/main/java/jsufec/Connection.java +2 -2
@@ 9,7 9,7 @@ import java.nio.ByteBuffer;
import java.lang.Exception;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.sql.Timestamp;
import java.util.Date;

import com.goterl.lazysodium.LazySodium;
import com.goterl.lazysodium.exceptions.SodiumException;


@@ 108,7 108,7 @@ public class Connection {
		}
		byte[] payloadBytes = this.encrypted.receive(payloadLength);
		ByteBuffer payloadBuffer = ByteBuffer.wrap(payloadBytes);
		Timestamp timestamp = new Timestamp(payloadBuffer.getLong());
		Date timestamp = new Date(payloadBuffer.getLong());
		byte[] messageBytes = new byte[payloadLength - Long.BYTES];
		payloadBuffer.get(messageBytes);
		byte[] confirmation = {0};

M src/main/java/jsufec/Message.java => src/main/java/jsufec/Message.java +4 -4
@@ 5,16 5,16 @@ import java.util.Date;
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.nio.BufferUnderflowException;
import java.sql.Timestamp;
import java.util.Date;

public class Message {
	public ArrayList<SufecAddr> otherRecipients;
	public Timestamp timestamp;
	public Date timestamp;
	public ArrayList<MessageHash> hashes;
	public MessageContent content;
	public Message(
		ArrayList<SufecAddr> otherRecipients,
		Timestamp timestamp,
		Date timestamp,
		ArrayList<MessageHash> hashes,
		MessageContent content
	) {


@@ 49,7 49,7 @@ public class Message {
			for (int i = 0; i < numOtherRecipients; i++) {
				recipients.add(SufecAddr.fromBytes(bytes));
			}
			Timestamp timestamp = new Timestamp(bytes.getLong());
			Date timestamp = new Date(bytes.getLong());
			ArrayList hashes = new ArrayList();
			int numHashes = bytes.get() & 0xff;
			for (int i = 0; i < numHashes; i++) {

M src/main/java/jsufec/MessageHash.java => src/main/java/jsufec/MessageHash.java +5 -5
@@ 1,25 1,25 @@
package jsufec;

import java.time.Instant;
import java.util.Date;
import java.nio.ByteBuffer;
import com.goterl.lazysodium.interfaces.Hash;

public class MessageHash {
	public Instant timestamp;
	public Date timestamp;
	public byte[] hash;
	public MessageHash(Instant timestamp, byte[] hash) {
	public MessageHash(Date timestamp, byte[] hash) {
		this.timestamp = timestamp;
		this.hash = hash;
	}
	public byte[] toBytes() {
		byte[] output = new byte[Long.BYTES + Hash.SHA512_BYTES];
		byte[] timestampBytes = ByteConv.longToBytes(this.timestamp.toEpochMilli());
		byte[] timestampBytes = ByteConv.longToBytes(this.timestamp.getTime());
		System.arraycopy(timestampBytes, 0, output, 0, Long.BYTES);
		System.arraycopy(this.hash, 0, output, Long.BYTES, Hash.SHA512_BYTES);
		return output;
	}
	public static MessageHash fromBytes(ByteBuffer bytes) {
		Instant timestamp = Instant.ofEpochMilli(bytes.getLong());
		Date timestamp = new Date(bytes.getLong());
		byte[] hash = new byte[Hash.SHA512_BYTES];
		bytes.get(hash);
		return new MessageHash(timestamp, hash);

M src/main/java/jsufec/MessageReceived.java => src/main/java/jsufec/MessageReceived.java +3 -3
@@ 1,12 1,12 @@
package jsufec;

import java.sql.Timestamp;
import java.util.Date;

public class MessageReceived {
	public Timestamp timestamp;
	public Date timestamp;
	public SufecAddr sender;
	public Message message;
	public MessageReceived(Timestamp timestamp, SufecAddr sender, Message message) {
	public MessageReceived(Date timestamp, SufecAddr sender, Message message) {
		this.timestamp = timestamp;
		this.sender = sender;
		this.message = message;