使用JAR文件中的静态变量

时间:2018-11-19 03:24:51

标签: java tink

我创建了一个可运行的JAR文件,其中包含带有以下代码的类:

var someRootPath = "@Url.Content("~")";

$(function(){

    randomGenerator();
    setTimeout(randomGenerator, 1000);

});
function randomGenerator() {
    $.ajax({
        url: someRootPath + 'Home/GetValue',
        success: function (data) {
            $('#pValue').html(data.someValue);
        }
    });
}

在另一个Java应用程序中,我已将此JAR文件作为外部JAR文件导入,并尝试运行以下方法:

static KeysetHandle keysetHandle = null;

public String encrypt(String plainText){

    Config.register(AeadConfig.TINK_1_1_0);

       // GENERATE key
       // key generated using tink library
       keysetHandle = KeysetHandle.generateNew(AeadKeyTemplates.AES256_GCM);
}

public String decrypt(String cipherText){

    //using the key generated during encryption to decrypt
                 Aead aeadDecryption = AeadFactory.getPrimitive(keysetHandle);

} 

加密功能按预期工作,但是解密返回import core.Crypto; public class Sample { public static void main(String[] args) { // TODO Auto-generated method stub Crypto crypto = new Crypto(); System.out.println(crypto.encrypt("sampleText")); System.out.println(crypto.decrypt("XXX")); } } ,因为NullPointerException为空。如何获取keysetHandle的更新值?

0 个答案:

没有答案
相关问题