lxw
2022-05-16 df770f80b2768f82150b30c98d693e8e8b8f57bb
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
package com.whyc.service;
 
import com.whyc.pojo.ComInfo;
import com.whyc.pojo.HardWareUtils;
import com.whyc.pojo.RSAUtil;
import com.whyc.pojo.Response;
import org.springframework.stereotype.Service;
 
@Service
public class ComInfoService {
 
    public Response getComInfoRSA(){
        ComInfo cInfo=new ComInfo();
        cInfo.setCpuId(HardWareUtils.getCPUSerial());
        cInfo.setCpuIdRsa(RSAUtil.encrypt(cInfo.getCpuId(),RSAUtil.getPublicKey()));
 
        cInfo.setBoardId(HardWareUtils.getMotherboardSN());
        cInfo.setBoardIdRsa(RSAUtil.encrypt(cInfo.getBoardId(),RSAUtil.getPublicKey()));
 
        return  new Response().setII(1,cInfo,cInfo!=null?true:false,"");
    }
 
    public Response getComInfo(ComInfo cInfo) {
        cInfo.setCpuId(RSAUtil.decrypt(cInfo.getCpuIdRsa(),RSAUtil.getPrivateKey()));
        cInfo.setBoardId(RSAUtil.decrypt(cInfo.getBoardIdRsa(),RSAUtil.getPrivateKey()));
        return  new Response().setII(1,cInfo,cInfo!=null?true:false,"");
    }
}