【Foxit PDF SDK for Web】如何更好地保护采购的授权码,使其只能在被允许的生产环境范围内进行使用?

1. 在WebSDK根目录下的server\license-protec下,新增一个js文件(如:encrypt_license.js),用于编写应用程序代码,代码详情如下:

global.self = global;

//make sure the following file path is correct.
var LicenseProtect = require('./index.js');
var license = require('../../examples/license-key.js')
var licenseProtect = new LicenseProtect('../../lib/jr-engine/gsdk/');

   

licenseProtect.encrypt(
    license.licenseSN,
    license.licenseKey,
    {
        // The domain white-list will be resolved into regular expression. 域名白名单,会解析成正则来匹配
        hosts: [
            '127.0.0.1:8848',
            '192.168.1.8:9103',
            'http://www.foxitsoftware.com',
            // 'http://www.foxitsoftware.cn',
            // /http:\/\/www.foxitsoftware.cn/
        ],
        // Validity start time, millisecond value  有效期开始时间,毫秒值
        begin: Date.now(),
        // Expiry end time, millisecond value  有效期结束时间,毫秒值
        end: Date.now()+3600000,
    }
).then(function (password) {
    //此处会输出一个授权码加密后的字符串,
    console.log('licenseProtect:', password);
})

2. server/license-protect/下打开控制台运行 `node encrypt_license.js`,生成licenseProtect值
3. 将步骤3执行生成的licenseProtect值复制到原先传递licenseKey和licenseSN的地方(\examples\UIExtension\advanced_webViewer\index.html),现在是传l (小写的L)

<script> 

    var readyWorker = preloadJrWorker['default']({
        workerPath: '../../../lib/'
        enginePath: '../lib/jr-engine/gsdk'
        fontPath: '../external/brotli'
        l:'licenseProtect值复制到这里' 
    }) 
</script>