改密增加加密功能
This commit is contained in:
@@ -112,11 +112,14 @@ public class AES {
|
||||
// byte key[] = "1234567890ABCDEF1234567890ABCDEf".getBytes("utf-8");//hexStringToBytes("0123456789ABCDEF");
|
||||
byte key[] = "1234567890ABCDEF1234567890ABCDEf".getBytes("utf-8");//hexStringToBytes("0123456789ABCDEF");
|
||||
|
||||
String src = "1234qwer";
|
||||
// decryptStr("80c813b346d2a6b66672dc852e1f4041");
|
||||
String src = "1234";
|
||||
System.out.println("密钥:"+byteToHexString(key));
|
||||
System.out.println("原字符串:"+src);
|
||||
|
||||
String enc = byteToHexString(encrypt(src, key));
|
||||
// String enc = byteToHexString(encrypt(src, key));
|
||||
String enc = "96842b85d4d95f87376ab2751e1f48cc";
|
||||
// String enc ="e185c23adc2fd81572dfb755b5a3eeb7";
|
||||
System.out.println("加密:"+enc);
|
||||
System.out.println("解密:"+new String(decrypt(enc, key), "utf-8"));
|
||||
} catch (InvalidKeyException e) {
|
||||
@@ -135,4 +138,5 @@ public class AES {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -68,6 +68,7 @@ public class BuiOperLoginAction extends BaseAction {
|
||||
}
|
||||
|
||||
BuiOperDO buiOperDO = buiOperMapper.selectByOperNo(reqBO.getOperNo());
|
||||
System.out.println(buiOperDO + "<--------buiOperDO");
|
||||
if (buiOperDO == null) {
|
||||
resultT.setMsgCod(CommonMessageCode.FAIL);
|
||||
resultT.setMsgInf("操作员或密码错误");
|
||||
@@ -128,7 +129,7 @@ public class BuiOperLoginAction extends BaseAction {
|
||||
|
||||
public static void main(String[] args) throws YGException {
|
||||
// 3c26b1141066531d856b6cd126d0834da814701c4ff8ec97f9b398bc32d6549f
|
||||
String encryptPwd = YGExpUtil.sha256("1" + "13695");
|
||||
String encryptPwd = YGExpUtil.sha256("123" + "770021");
|
||||
|
||||
System.out.println(encryptPwd);
|
||||
}
|
||||
|
||||
+7
-7
@@ -39,7 +39,7 @@ public class BuiOperUpdatePasswordAction extends BaseAction {
|
||||
* @return
|
||||
* @throws YGException
|
||||
*/
|
||||
public ResultT execute(YGBizMessageContext bizCtx, BuiOperUpdatePasswordReqBO reqBO) throws YGException {
|
||||
public ResultT execute(YGBizMessageContext bizCtx, BuiOperUpdatePasswordReqBO reqBO) throws Exception {
|
||||
YGBizMessage bizMsg = bizCtx.getCurrentMsg();
|
||||
Logger msgLog = YGLogger.getLogger(bizMsg);
|
||||
msgLog.info("updatePassword, reqBO=" + JSONObject.toJSON(reqBO));
|
||||
@@ -61,19 +61,19 @@ public class BuiOperUpdatePasswordAction extends BaseAction {
|
||||
resultT.setMsgInf("操作员没有找到");
|
||||
return resultT;
|
||||
}
|
||||
|
||||
String encryptPwd = YGExpUtil.sha256(reqBO.getOperPwd() + entity.getPwdSalt());
|
||||
|
||||
if (!StringUtils.equals(entity.getOperPwd(), encryptPwd)) {
|
||||
resultT.setMsgCod(CommonMessageCode.FAIL);
|
||||
resultT.setMsgInf("原密码错误");
|
||||
return resultT;
|
||||
}
|
||||
String password = AES.decryptStr(reqBO.getNewOperPwd());
|
||||
msgLog.info("password:" + password);
|
||||
|
||||
|
||||
encryptPwd = YGExpUtil.sha256(reqBO.getNewOperPwd() + entity.getPwdSalt());
|
||||
|
||||
entity.setOperPwd(encryptPwd);
|
||||
System.out.println("password" + password);
|
||||
String enc = YGExpUtil.sha256(password + entity.getPwdSalt());
|
||||
System.out.println("加密:" + enc);
|
||||
entity.setOperPwd(enc);
|
||||
int retCode = buiOperMapper.updateByPrimaryKeySelective(entity);
|
||||
|
||||
if (retCode > 0) {
|
||||
|
||||
Reference in New Issue
Block a user