更新加密和解密的模块
This commit is contained in:
parent
605a887041
commit
4ee8318869
13
pom.xml
13
pom.xml
@ -35,13 +35,24 @@
|
||||
</developers>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.doubleclick</groupId>
|
||||
<artifactId>doubleclick-openrtb</artifactId>
|
||||
<version>2.0.4-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
<!-- LOGGING WITH SELF4J AND LOG4J2 -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.36</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
@ -1,11 +1,15 @@
|
||||
package com.ossez.framework.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.doubleclick.crypto.DoubleClickCrypto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.InvalidKeyException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author YuCheng
|
||||
@ -28,6 +32,23 @@ public class GoogleEncryptionService {
|
||||
*/
|
||||
public String decryptPrice(String url) {
|
||||
|
||||
String encryptionKey ="encryption";
|
||||
String integrityKey = "integrityKey";
|
||||
;
|
||||
DoubleClickCrypto.Keys keys = null;
|
||||
try {
|
||||
keys = new DoubleClickCrypto.Keys(
|
||||
new SecretKeySpec(Base64Utils.encode(encryptionKey.getBytes()), "HmacSHA1"),
|
||||
new SecretKeySpec(Base64Utils.encode(integrityKey.getBytes()), "HmacSHA1"));
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
DoubleClickCrypto.Price crypto = new DoubleClickCrypto.Price(keys);
|
||||
|
||||
// String encodedPrice = httpRequest.getHeader("price");
|
||||
// double price = crypto.decodePriceValue(encodedPrice);
|
||||
|
||||
|
||||
return "my-decryptPrice-String";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user