Commit e8dcd3a6 authored by renjie's avatar renjie

用户加密密码

parent c4199812
......@@ -691,7 +691,7 @@ public class AccountServiceImpl implements AccountService {
}
public static String makeRandomPassword(int len){
char charr[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@$%^&*.?".toCharArray();
char charr[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".toCharArray();
StringBuilder sb = new StringBuilder();
Random r = new Random();
for (int x = 0; x < len; ++x) {
......@@ -734,9 +734,8 @@ public class AccountServiceImpl implements AccountService {
User authUser = new User();
authUser.setUsername(user.getName());
String password;
if (org.apache.commons.lang3.StringUtils.isNotBlank(subUsersRequestDto.getPassword())) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(subUsersRequestDto.getPassword()))
password = Aes.aesDecrypt(subUsersRequestDto.getPassword());
}
else
password = makeRandomPassword(8);
......@@ -763,8 +762,8 @@ public class AccountServiceImpl implements AccountService {
if (user.getWhiteList() != null && user.getWhiteList().size() > 0)
whiteList.addAll(user.getWhiteList());
account.setWhiteList(whiteList);
password = Aes.aesEncrypt(password);
account.setPassword(password);
String newpassword = Aes.aesEncrypt(password);
account.setPassword(newpassword);
repository.save(account);
// emailService.sendEmailVerification(user.getUsername(), user.getEmail(), user.getVerificationCode());
......
......@@ -153,12 +153,12 @@ public class Aes {
* 测试
*/
public static void main(String[] args) throws Exception {
String content = "123";
System.out.println("加密前:" + content);
System.out.println("加密密钥和解密密钥:" + KEY);
String encrypt = aesEncrypt(content, KEY);
System.out.println("加密后:" + encrypt);
String decrypt = aesDecrypt(encrypt, KEY);
String content = "VHRg3tocHf9i2Q27COKDhw==";
// System.out.println("加密前:" + content);
// System.out.println("加密密钥和解密密钥:" + KEY);
// String encrypt = aesEncrypt(content, KEY);
// System.out.println("加密后:" + encrypt);
String decrypt = aesDecrypt(content, KEY);
System.out.println("解密后:" + decrypt);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment