需要帮助加密和解密一个文件在java?

需要帮助加密和解密一个文件在java?

问题描述:

我想在java中加密和解密一个文件,我已经读过这个url http://www-users.york.ac.uk/~mal503/lore/pkencryption.htm ,并得到两个文件,即公共安全证书和私人安全证书文件和private.pem文件,我复制这些文件并粘贴在当前目录,当我运行这我得到这个错误java.security.InvalidKeyException:非法的密钥大小或默认参数,我认为可能是openssl密钥生成错误,pls指南在正确的路径。

I want to encrypt and decrypt a file in java, i had read this url http://www-users.york.ac.uk/~mal503/lore/pkencryption.htm and got two files namely public Security certificate and private security certificate file and private.pem file, i copied these files and pasted in the current directory , when i run this i got this error java.security.InvalidKeyException: Illegal key size or default parameters,i think may be openssl key generation is wrong, pls guide in proper path.

Java只有弱加密,并且不允许由openssl创建正确的键大小。修正非常简单。

Java ships with only weak encryption, and simply will not allow the proper key sizes being created by openssl. The fix is happily very simple.

如果您访问这里是一个题为Java Cryptography Extension(JCE)Unlimited Strength Jurisdiction Policy Files 6的下载。这将为您提供一个包含4个文件的ZIP文件。这些文件之一是README,其中详细说明了您对其他文件的操作。

If you go to here at the bottom of the page is a download entitled "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6". This will provide you with a ZIP file containing 4 files. One of these files is a README which has detailed instructions on what you do with the other files.

安装这些策略文件后,您可以使用强加密,没有得到这个错误消息简单地使用AES-256密码。

Once you have these policy files installed, you can use strong encryption and will not get this error message simply from using an AES-256 cipher.