我正在尝试使用AES/GCM/NoPadding加密和解密数据.我安装了JCE Unlimited Strength Policy Files并在下面运行了(简单的)基准测试.我使用OpenSSL做了同样的事情,并且能够在我的PC上实现超过1 GB/s的加密和解密.
使用下面的基准测试,我只能在同一台PC上使用Java 8进行3 MB/s的加密和解密.知道我做错了什么吗?
public static void main(String[] args) throws Exception {
final byte[] data = new byte[64 * 1024];
final byte[] encrypted = new byte[64 * 1024];
final byte[] key = new byte[32];
final byte[] iv = new byte[12];
final Random random = new Random(1);
random.nextBytes(data);
random.nextBytes(key);
random.nextBytes(iv);
System.out.println("Benchmarking AES-256 GCM encryption for 10 seconds");
long javaEncryptInputBytes = 0;
long javaEncryptStartTime = System.currentTimeMillis();
final Cipher javaAES256 = Cipher.getInstance("AES/GCM/NoPadding");
byte[] tag …Run Code Online (Sandbox Code Playgroud) 我RestTemplate在java中使用spring 编写REST客户端,在使用'HTTPBuilder'时使用groovy 编写REST客户端.两次调用都在我的电脑上花了10秒钟.在Postman和其他工具中,这种相同的帖子请求需要300毫秒.
这是groovy脚本中的简单调用.必需是间BEGIN REST invocation和END REST invocation:
@Grapes(
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7')
)
import groovy.json.JsonOutput
import groovy.json.internal.LazyMap
import groovy.transform.ToString
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.JSON
import static groovyx.net.http.Method.POST
HTTPBuilder http = new HTTPBuilder()
Forechart forechart = new Forechart(dayInterval: 3, adultCount: 1, childCount: 0,
flightList: [new Flight(departureStation: "WAW", arrivalStation: "CRL", date: new Date(2018, 06, 02))
,new Flight(departureStation: "CRL", arrivalStation: "WAW", date: new Date(2018, 10, 26))])
def jsonRequest = JsonOutput.toJson( forechart …Run Code Online (Sandbox Code Playgroud)