zhongrj
2023-10-19 aa6fd3986a72524dea1547f2b1cce85ea71228bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cn.gistack.pwd.service.impl;
 
import cn.gistack.pwd.dto.CBCResultDTO;
import cn.gistack.pwd.entity.VerifyOutput;
import cn.gistack.pwd.mapper.VerifyOutputMapper;
import cn.gistack.pwd.service.IPwdSendService;
import cn.gistack.pwd.service.IVerifyOutputService;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
 
@Service
@AllArgsConstructor
public class VerifyOutputServiceImpl extends BaseServiceImpl<VerifyOutputMapper, VerifyOutput> implements IVerifyOutputService {
 
    private final IPwdSendService pwdSendService;
 
    @Override
    public Boolean verifyMaced(String maced,String sm4Iv, String keyIndex,String dataId, String source, String message) {
 
        CBCResultDTO cbcMacEncipher = pwdSendService.getCBCMacEncipher(sm4Iv, keyIndex, message);
 
        String newMaced = cbcMacEncipher.getMaced();
 
        String result = "验证成功,数据未被篡改";
 
 
        boolean equals = maced.equals(newMaced);
        //不等于
        if (!equals){
            result = "验证失败,数据已被篡改";
        }
 
        VerifyOutput verifyOutput = new VerifyOutput();
 
        verifyOutput.setDataId(dataId);
        verifyOutput.setSource(source);
        verifyOutput.setResult(result);
        verifyOutput.setMessage(message);
        verifyOutput.setMessageVerify(newMaced);
        verifyOutput.setMaced(maced);
 
        return save(verifyOutput);
    }
}