Java outputstream中缺少数字(包含完整的详细信息)

Java outputstream中缺少数字(包含完整的详细信息),java,encryption,aes,Java,Encryption,Aes,(对于版主-这是第三个仍然未解决问题的相关帖子,现在我发布了所有可能的细节,并且在对以前的帖子反馈进行了更改之后,虽然这是一个完整的帖子,不依赖以前的两篇帖子,如果您认为这是重复的,请删除以前的帖子。谢谢) 这是函数的代码 public void decrypt(final InputStream cph_in, final OutputStream out) { InputStream in; try { // Bytes read from in will be decr

(对于版主-这是第三个仍然未解决问题的相关帖子,现在我发布了所有可能的细节,并且在对以前的帖子反馈进行了更改之后,虽然这是一个完整的帖子,不依赖以前的两篇帖子,如果您认为这是重复的,请删除以前的帖子。谢谢)

这是函数的代码

public void decrypt(final InputStream cph_in, final OutputStream out)
 {
  InputStream in;
  try
  {
   // Bytes read from in will be decrypted
   in = new CipherInputStream(cph_in, dcipher);

   // Read in the decrypted bytes and write the cleartext to out
   int numRead = 0;
   //System.out.println(in.read(buf));
   while ((numRead = in.read(buf)) >= 0)
   {
    out.write(buf, 0, numRead);
    System.out.println(numRead);
   }
   //out.close();
  }
  catch (java.io.IOException e)
  {
  }
 ByteArrayInputStream in = null;
    FileOutputStream out = null;

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");
这里是控制台输出

the Cell Content : ;Xéü¿Uô{¼9¬ðM
3
the Cell Content : ïB
the Cell Content : þ^[ÊN=—î™ì4´•z&
3
the Cell Content : @ûú!Í?+²uŸK^/?¤
3
the Cell Content : ´ƒôœCëîé V­¢%
3
the Cell Content : q^ŽÐâ\Æn2bšcU
3
the Cell Content : ?³j8¥+¤
the Cell Content : R
the Cell Content : 3ex­Ê]ý­v>>|Äð
3
the Cell Content : š¾‚ýËe©%Ä»
the Cell Content : Æ´=OöÀ¶+'¸e£Ñßpö
3
the Cell Content : etO­„ïŸÞñ?Æü é
the Cell Content : çë
当我将outputstream放入excel时,它看起来是这样的(注释124、129130等缺失)

***问题就在这里。。为什么有些数字不见了

123

125
126
127
128


131

133

135

137
138
139
140
141

143
144
下面是对函数的调用

public void decrypt(final InputStream cph_in, final OutputStream out)
 {
  InputStream in;
  try
  {
   // Bytes read from in will be decrypted
   in = new CipherInputStream(cph_in, dcipher);

   // Read in the decrypted bytes and write the cleartext to out
   int numRead = 0;
   //System.out.println(in.read(buf));
   while ((numRead = in.read(buf)) >= 0)
   {
    out.write(buf, 0, numRead);
    System.out.println(numRead);
   }
   //out.close();
  }
  catch (java.io.IOException e)
  {
  }
 ByteArrayInputStream in = null;
    FileOutputStream out = null;

    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");
/*KeyGenerator kgen=KeyGenerator.getInstance(“AES”); kgen.init(128); SecretKey=kgen.generateKey(); byte[]encoded=key.getEncoded()

write(编码的新文件输出流(新文件(“C:\Users\abc\Desktop\key.txt”))*/

FileInputStream fin=新的FileInputStream(“C:\key.txt”); DataInputStream din=新的DataInputStream(fin)

字节b[]=新字节[16]

din.read(b)

InputStream excelResource=新文件InputStream(路径);
工作簿rwb=Workbook.getWorkbook(excelResource);
int sheetCount=rwb.getNumberOfSheets();
图纸rs=rwb.getSheet(0);
int rows=rs.getRows();
int cols=rs.getColumns();

对于(int i=0;i您无法将密文(二进制)可靠地存储到单元格中。我怀疑编码弄乱了一些单元格。请尝试对密文进行base64或hex编码,然后将其存储在单元格中


如果您必须使用原始二进制,请确保您的编码在任何地方都是拉丁-1。拉丁-1保留二进制序列。

您能告诉我如何实现这两种方法之一吗