【发布时间】:2011-09-18 05:26:24
【问题描述】:
所以我正在尝试用 java 编写一个steganography 程序。
这是我目前所拥有的(重要部分)
private void hideMessage(){
byte[] messageBytes = message.getBytes();
//message is a string
int messageLength = messageBytes.length;
for(int i = messageLength-1; i>=0; i--){
imageBytes[i+100000] = messageBytes[i];
//imageBytes is a bitmap image read into a byte array using imageIO
}
}
和
private void getMessage(){
int messageLength = 11;
byte[] messageBytes = new byte[messageLength];
for(int i = messageLength; i>0; i--){
messageBytes[i-1] = imageBytes[i+10000];
}
message = new String(messageBytes);
}
但是这是我得到的字符串输出:
???????????
我做错了什么?
【问题讨论】:
-
@Alex,我看不出你发布的任何代码都可以编译...请清理一下。
-
@mre 我正在使用 System.out.println(message);
-
@Martijn 我使用 +1000 来避免写入文件的标题。否则它告诉我它无法读取文件。
-
你是在操作图像文件的纯字节,还是解码后/编码前的图像数据?
-
@bemace 感谢您的关注。
标签: java string byte bytearray steganography