Skip to content

Commit e401aba

Browse files
committed
changed something when working on PKI CLI in SharkMessenger. Mostly, util functions.
1 parent c16045e commit e401aba

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main/java/net/sharksystem/utils/SerializationHelper.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package net.sharksystem.utils;
22

3+
import net.sharksystem.asap.ASAPException;
4+
import net.sharksystem.asap.utils.ASAPSerialization;
5+
36
import java.io.*;
47
import java.util.*;
58

@@ -48,14 +51,15 @@ public static byte[] long2byteArray(long value) {
4851
return result;
4952
}
5053

51-
public static byte[] characterSequence2bytes(CharSequence cs) {
52-
// TODO - that's ok?
53-
return cs.toString().getBytes();
54+
public static byte[] characterSequence2bytes(CharSequence cs) throws IOException {
55+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
56+
ASAPSerialization.writeCharSequenceParameter(cs, baos);
57+
return baos.toByteArray();
5458
}
5559

56-
public static CharSequence bytes2characterSequence(byte[] bytes) {
57-
// TODO - that's ok?
58-
return new String(bytes);
60+
public static CharSequence bytes2characterSequence(byte[] bytes) throws IOException, ASAPException {
61+
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
62+
return ASAPSerialization.readCharSequenceParameter(bais);
5963
}
6064

6165
public static List<CharSequence> string2CharSequenceList(String s) {

0 commit comments

Comments
 (0)