2011-02-05 4 views
0

私はこのコードを何か似たような時間をWebアプリケーションのサーバーコード内で使用しましたが、今はコマンドを作成しようとしていますメンテナンスバックエンドで作業するためのオンラインユーティリティです。Miffed ...シンプルなコードですが、org.jasypt.exceptions.EncryptionOperationNotPossibleException

EncryptionOperationNotPossibleExceptionを取得し続けるが、コードで何が間違っているのかわからない。スニペットをテストするために、実際の暗号化された文字列を使用してテスト入力ではないことを確認しました。

この例外はコード内のどこにありますか?

import org.jasypt.exceptions.EncryptionOperationNotPossibleException; 
import org.jasypt.util.text.BasicTextEncryptor; 

public class decipher { 

    /** 
    * @param args 
    */ 
    public static void main(String[] args) { 
     if (args[0] != null) { 
      String encstr = args[0]; 
      String decstr = ""; 

      if (encstr != null && !encstr.equals("")) { 
       try { 
        BasicTextEncryptor textEncryptor = new BasicTextEncryptor(); 
        textEncryptor.setPassword("1234566789"); 
        decstr = textEncryptor.decrypt(encstr); 
        System.out.println(decstr); 
       } catch (EncryptionOperationNotPossibleException e) { 
        System.out.println(e.toString()); 
       } 
      } else { 
       System.out.println("Passed empty string... not decrypted."); 
      } 
     } else { 
      System.out.println("This program requires and encrypted text input."); 
     } 
    } 
} 

答えて

2

固定!私が使用していた入力文字列は、最初は有効な暗号化文字列ではなかったことが判明しました!まず、暗号化、コピー、および文字列を使ってスクリプトを実行し、その文字列に対して復号化を実行します。

関連する問題