简体   繁体   English

Java密码加密

[英]Java password encryption

We have a maven project for website automation . 我们有一个用于网站自动化的Maven项目。 Website uses a login and password to enter into first page . 网站使用登录名和密码进入首页。 Is it possible to have a something like below. 是否有可能像下面这样。

  1. Passcord is encrpted in some format in a property file so that even if someone downloads the entire maven project it is will not be visible in plain txt . Passcord以某种格式记录在属性文件中,因此,即使有人下载了整个maven项目,也不会以纯txt格式显示它。
  2. Selenium takes encrpted password from property file and decrypts it and enters into website . Selenium从属性文件中获取加密的密码,然后解密并进入网站。

You can use Jasypt cli (command line) utility that can be used to encrypt the values of your properties. 您可以使用Jasypt cli(命令行)实用程序,该实用程序可用于加密属性的值。 Download the Jasypt distribution and unpack it. 下载Jasypt发行版并解压缩。 The utilities reside in the bin directory. 这些实用程序位于bin目录中。

C:\jasypt-1.7\bin> encrypt input=postgres password=secret


----ARGUMENTS-------------------

input: postgres
password: secret

----OUTPUT----------------------

jd5ZREpBqxuN9ok0IhnXabgw7V3EoG2p

For detailed steps and do/don'ts you can refer to this page and this page 有关详细步骤和可以执行的操作,请参考页面和页面

If you're providing someone with the code used to decrypt the password, there is no way you can encrypt it that will hide it from someone determined. 如果您要向某人提供用于解密密码的代码,则无法加密它,从而无法将其隐藏。 You would be providing them with both the encrypted password, and the means to decrypt it. 您将为他们提供加密的密码以及解密密码的方法。

However, what you can do it not include the properties file which contains the password in the maven project, and then users have to input this themselves. 但是,您不能执行的操作不包括在maven项目中包含密码的属性文件,然后用户必须自己输入该文件。

Dependent on what you are doing this might not be ideal however. 但是,取决于您执行的操作可能并不理想。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM