| | |
| | | |
| | | //加密后存储的位置 |
| | | File metaDir = new File(this.targetDir, "META-INF" + File.separator + Const.FILE_NAME); |
| | | File descriptionDir = new File(this.targetDir, "META-INF" + File.separator); |
| | | if (!metaDir.exists()) { |
| | | metaDir.mkdirs(); |
| | | } |
| | | |
| | | //无密码模式,自动生成一个密码 |
| | | if (this.password.length == 1 && this.password[0] == '#') { |
| | | /*if (this.password.length == 1 && this.password[0] == '#') { |
| | | char[] randChars = EncryptUtils.randChar(32); |
| | | this.password = EncryptUtils.md5(randChars); |
| | | File configPass = new File(metaDir, Const.CONFIG_PASS); |
| | | IoUtils.writeFile(configPass, StrUtils.toBytes(randChars)); |
| | | }*/ |
| | | |
| | | //密码文件生成 |
| | | if (this.password.length == 1 && this.password[0] == '#') { |
| | | char[] randChars2 = Const.FILE_NAME2_DESCRIPTION.replace(" ", "").toCharArray(); |
| | | //密码为混淆 原码+盐 |
| | | this.password = StrUtils.merger(randChars2, EncryptUtils.SALT); |
| | | String password2 = EncryptUtils.enAES(Arrays.toString(password), Const.AES_KEY.toCharArray()); |
| | | File configPass = new File(descriptionDir, Const.FILE_NAME2); |
| | | //将混淆后的密码加密后存储 |
| | | IoUtils.writeFile(configPass, password2.getBytes()); |
| | | } |
| | | |
| | | //有机器码 |