0

Web アプリのサーバー コード内でこのコードまたは同様のコードを何度も使用しましたが、現在、メンテナンス バックエンドで動作するコマンド ライン ユーティリティを作成しようとしています。

を取得し続け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.");
        }
    }
}
4

1 に答える 1

2

修理済み!!私が使用していた入力文字列は、そもそも有効な暗号化された文字列ではなかったことがわかりました!! 最初に文字列を暗号化し、コピーして貼り付けてスクリプトを実行し、次にその文字列に対して復号化を実行します...

于 2011-02-05T05:26:43.353 に答える