Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何转换字节[]中自定义类的此对象?_Java - Fatal编程技术网

Java 如何转换字节[]中自定义类的此对象?

Java 如何转换字节[]中自定义类的此对象?,java,Java,我在用电话。我有两个byte[]值,我正在使用Scapi的安全通道发送给接收器 发送方: byte[] x0 = keysArray[0][0].getBytes(); byte[] x1 = keysArray[0][1].getBytes(); OTOnByteArraySInput input = new OTOnByteArraySInput(x0, x1); Channel channel = obliviousTransferChannelCreation(); sender.t

我在用电话。我有两个
byte[]
值,我正在使用Scapi的安全通道发送给接收器

发送方

byte[] x0 = keysArray[0][0].getBytes();
byte[] x1 = keysArray[0][1].getBytes();

OTOnByteArraySInput input = new OTOnByteArraySInput(x0, x1);

Channel channel = obliviousTransferChannelCreation();
sender.transfer(channel, input);
byte sigma = 0;
OTRBasicInput input = new OTRBasicInput(sigma);
Channel channel = obliviousTransferChannelCreation();
OTROutput output = null;

output = receiver.transfer(channel, input);
接收者根据他的西格玛得到两个值中的一个

接收器

byte[] x0 = keysArray[0][0].getBytes();
byte[] x1 = keysArray[0][1].getBytes();

OTOnByteArraySInput input = new OTOnByteArraySInput(x0, x1);

Channel channel = obliviousTransferChannelCreation();
sender.transfer(channel, input);
byte sigma = 0;
OTRBasicInput input = new OTRBasicInput(sigma);
Channel channel = obliviousTransferChannelCreation();
OTROutput output = null;

output = receiver.transfer(channel, input);

此时,我想再次将
输出
转换为
字节[]
(然后转换为字符串)。但是
output
OTROutput
的对象。我在中找不到将
otr输出
转换为
byte[]
(或任何相关内容)的方法。是否有将自定义类转换为字节[]的选项?

一旦将其转换为字符串,您需要对其做什么?不要使用
String
存储二进制数据!特别是因为它的
.getBytes()
方法依赖于JVM的默认值encoding@JoshChappelle读一下
keysArray[0][0]
是一个字符串(可以是一条消息,即“Hello”)。为了通过Channel类发送,我必须将其转换为字节[]。当它到达接收者时,我想再次阅读消息。