You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.
Implementation of Entity#getBytes is currently mName.getBytes("UTF-16"), but it should be either mName.getBytes("UTF-16BE") or mName.getBytes("UTF-16LE")
detail
I am trying to implement java cli app to decrypt files encrypted by conceal, and getting tag mismatch error all the time.
And after some investigation I realized that the result of String.getBytes("UTF-16") is different between Android and Mac.
when I execute Arrays.toString("teststring".getBytes("UTF-16")) on Android, it returns
Apparently this is why I got tag mismatch error all the time :(
To fix this issue, I create custom Entity class whose getBytes method encodes mName with UTF-16LE.
But I think this should be done in library side. any thought?
The text was updated successfully, but these errors were encountered:
yshrsmz
changed the title
String.getBytes("UTF-16") returns different value on different platforms
String.getBytes("UTF-16") returns different value on Mac
Apr 7, 2016
You're totally right. We didn't bump into this problem as we used the encryption mainly for local storage, not for sharing stored data with other agents. I was thinking that UTF-8 could have even better byte distribution (as it doesn't pad with 0's).
But whatever we choose it should be the same among platforms.
Also: we should provide a way to read data persisted with current version to avoid backward incompatibility. I'll look into that soon.
TL; DR
Implementation of
Entity#getBytes
is currentlymName.getBytes("UTF-16")
, but it should be eithermName.getBytes("UTF-16BE")
ormName.getBytes("UTF-16LE")
detail
I am trying to implement java cli app to decrypt files encrypted by conceal, and getting
tag mismatch
error all the time.And after some investigation I realized that the result of
String.getBytes("UTF-16")
is different between Android and Mac.when I execute
Arrays.toString("teststring".getBytes("UTF-16"))
on Android, it returnsbut when I execute same code on mac as gradle task or standard java project, it returns
Apparently this is why I got
tag mismatch
error all the time :(To fix this issue, I create custom Entity class whose
getBytes
method encodesmName
with UTF-16LE.But I think this should be done in library side. any thought?
The text was updated successfully, but these errors were encountered: