【问题标题】:How to resolve java.security.spec.InvalidKeySpecException: Password is not ASCII如何解决 java.security.spec.InvalidKeySpecException:密码不是 ASCII
【发布时间】:2022-05-04 18:27:01
【问题描述】:

我有一个名为 test_PBE_Triple_DES 的测试,这里我使用 PBE_DES3_CBC_SHA1_ALGORITHM 来解码加密的密码,但每当我尝试执行它时,我都会收到一条错误消息,提示密码不是 ascii。

我在下面提供了堆栈跟踪。

com.tibco.security.AXSecurityException: java.security.spec.InvalidKeySpecException: Password is not ASCII
    at com.tibco.security.providers.CryptoVendorImpl_j2se.rename(CryptoVendorImpl_j2se.java:205)
    at com.tibco.security.Crypto.rename(Crypto.java:59)
    at com.tibco.security.TestPassword.test_PBE_Triple_DES(TestPassword.java:105)
Caused by: java.security.spec.InvalidKeySpecException: Password is not ASCII
    at com.sun.crypto.provider.PBEKey.<init>(PBEKey.java:64)
    at com.sun.crypto.provider.PBEKeyFactory.engineGenerateSecret(PBEKeyFactory.java:219)
    at javax.crypto.SecretKeyFactory.generateSecret(SecretKeyFactory.java:330)
    at com.tibco.security.providers.CryptoVendorImpl_j2se.rename(CryptoVendorImpl_j2se.java:161)

【问题讨论】:

标签: java-security


【解决方案1】:

万一有人遇到这种情况,我正在从系统上的一个文件中读取密码,并且它有一个由 vim 自动附加在其末尾的换行符。在我在 vim 中关闭该功能后,它工作正常。

以下是禁用换行的方法。 How to stop VIM from adding a newline at end of file?

【讨论】:

    【解决方案2】:

    是的,就我而言,添加了换行符。刚刚添加了 trim 方法,它得到了解决

    【讨论】:

    • 这看起来更像是一个评论,而不是一个新的答案。
    猜你喜欢
    • 1970-01-01
    • 2016-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-19
    • 1970-01-01
    相关资源
    最近更新 更多