(モデレーターへ-これはまだ解決されていない問題の3番目の関連投稿です。これは完全な投稿であり、以前の2つの投稿に依存していませんが、可能な限りすべての詳細を投稿し、以前の投稿のフィードバックから変更を加えた後です。重複している場合は、以前の投稿を削除してください。ありがとうございます)
これは関数のコードです
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)
{
}
これがコンソール出力です
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 : çë
出力ストリームをExcelに入れると、次のようになります(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 [] encoding = key.getEncoded();
IOUtils.write(encoded、new FileOutputStream(new File( "C:\ Users \ abc \ Desktop \ key.txt"))); * /
FileInputStream fin = new FileInputStream( "C:\ key.txt"); DataInputStream din = new 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 リンクテキスト (jarですが実行可能ではありません。抽出されます)にソースコードをアップロードしています。プログラムは動作します
Eclipseにインポートし、目的のApacePOIライブラリを提供した後。たとえば123から144までのc:\ MyExcel.xlsと呼ばれるexcelファイルの最初の列にデータを入れる必要があります。DoEncryption.javaを実行する必要があります。これにより、MyExcel.xlsからのすべてのデータがcの128ビットキーAES暗号化形式に変換されます。 :\ workbook.xlsとc:\ key.txtの作成workbook.xlsとkey.txtがcディレクトリに存在し、DoDecryption.javaを実行すると、復号化されたすべてのデータを含むc:\ Decrypted.xlsが作成され、元のデータと同じになります。 MyExcel.xls
コードの一部は使用されていないため、問題を解決するには、このシーケンスのみに従ってください。
みんな助けてください。mあなたを頼りに。