2009-11-25 3 views
0

(운영자에게 - 이것은 아직 해결되지 않은 문제의 3 번째 관련 게시물입니다. 이제는 모든 세부 사항을 게시하고 이전 게시물 피드백에서 변경 한 후 이제 완료되었습니다. 당신이 생각하는 경우 게시물 이전이 게시물에 의존하지 않는, 이것은 이전 게시물을 삭제하시기 바랍니다 중복입니다. 감사합니다)출력 스트림에 누락 된 번호

이 콘솔 출력

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 : çë 
기능 여기

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) 
    { 
    } 

의 코드입니다내가 엑셀에서의 OutputStream 넣으면없는 몇 가지 숫자가 왜 617,451,515,

그것은 .. 문제가있다 여기에 *** (실종 124, 129, 130 등주의)

다음과 같습니다. 여기

123 

125 
126 
127 
128 


131 

133 

135 

137 
138 
139 
140 
141 

143 
144 

은 함수 호출이다

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 key = kgen.generateKey(); byte [] encoded = key.getEncoded();

IOUtils.write (부호화 FileOutputStream에 새로운 (새 파일 ("C : \ 사용자 \ ABC \ 화상 \ key.txt"))); */

FileInputStream의 핀 = FileInputStream에 새로운 ("C : \ key.txt "); DataInputStream din = 새 DataInputStream (fin);

바이트 b [] = 새로운 바이트 [16];

din.read (b);

 InputStream excelResource=new FileInputStream(path); 
     Workbook rwb=Workbook.getWorkbook(excelResource); 
     int sheetCount=rwb.getNumberOfSheets(); 
     Sheet rs=rwb.getSheet(0); 
     int rows=rs.getRows(); 
     int cols=rs.getColumns(); 
      for(int i=0;i<rows;i++){ 
     for(int j=0;j<Col.length;j++){ 
       String theCell_00=rs.getCell(j,i).getContents(); 
       System.out.println("the Cell Content : "+theCell_00); 

       in = new ByteArrayInputStream(theCell_00.getBytes()); 
        out = new FileOutputStream("c:\\Decrypted.txt"); 

       try 
      { 

       //System.out.println(b); 
       SecretKey key1 = new SecretKeySpec(b, "AES"); 
       // Create encrypter/decrypter class 
       AESDecrypter encrypter = new AESDecrypter(key1); 

       encrypter.encrypt(new ByteArrayInputStream(theCell_00.getBytes()),new FileOutputStream("temp.txt")); 
       // Decrypt 
       // encrypter.encrypt(,new FileOutputStream("Encrypted.txt")); 

         encrypter.decrypt(in, out); 

와 내가 코드의 경우에도 나머지 그래서 난 http://www.filesavr.com/aesencryption link text (항아리가 아니라 실행. 추출되는)에서 소스 코드를 업로드하고 필요합니다 느낌이 이는 방법 프로그램 작동

Eclipse로 가져 와서 원하는 Apace POI 라이브러리를 제공 한 후. 예 : 123 to 144 DoEncryption.java를 실행해야합니다. MyExcel.xls의 모든 데이터가 128 비트 키 AES로 변환됩니다. 예 : 123에 대해 c : \ MyExcel.xls라는 Excel 파일의 첫 번째 열에 데이터를 입력해야합니다. c : \ workbook.xls에 암호화 된 양식 또한 c : \ key.txt를 만듭니다 workbook.xls 및 key.txt가 c 디렉토리에 있고 DoDecryption.java를 실행하면 모든 데이터가 포함 된 c : \ Decrypted.xls가 만들어집니다 단지

얘들 아 도와주세요 코드의 부분 중 일부는 심지어 문제를 해결하기 위해 그렇게 사용하지

MyExcel.xls로 원래 같은 얻기 위해 암호 해독은이 순서를 따르십시오 나 밖으로. 너를 믿어.

답변

1

셀에 2 진수 인 암호문을 안정적으로 저장할 수 없습니다. 나는 인코딩이 세포의 일부를 엉망으로 만든 것으로 의심한다. 암호문을 base64 또는 16 진수로 인코딩 한 다음 셀에 저장하십시오.

원시 바이너리를 사용해야하는 경우 인코딩이 모든 지역의 라틴어 -1인지 확인하십시오. Latin-1은 바이너리 시퀀스를 보존합니다.

+0

그 중 하나를 구현하는 방법을 알려주시겠습니까? – rover12

관련 문제