https://kotlinlang.org logo
#announcements
Title
# announcements
p

pdegand

12/05/2017, 10:59 AM
Hi, generic Java/Kotlin question: Can I always swap the usage of a
ByteArray
to a
String
and the otherway arround ? I'm doing some crypto and
Cipher
is using
ByteArray
as its input but i want to put the input inside a
data class
and
data class
are not happy with
Arrays
. So can i simply convert the the ByteArray to string to store inside my data class and re-convert the string to bytearray when i need to pass it to a cipher ?
p

pdvrieze

12/05/2017, 7:34 PM
This is extremely awkward due to multi-word code points. Strings expect to work as text, arbitrary data doesn't work as text. If you want to do it you want to do something like base64 encode your data (or similar higher density encodings like PDF uses)