自定义源新增version字段,新增utils.buffer.bufToString方法

This commit is contained in:
lyswhut
2021-10-07 12:28:03 +08:00
parent 68518e609d
commit d4240006f1
3 changed files with 16 additions and 3 deletions
+5 -1
View File
@@ -185,7 +185,7 @@ contextBridge.exposeInMainWorld('lx', {
utils: {
crypto: {
aesEncrypt(buffer, mode, key, iv) {
const cipher = createCipheriv('aes-128-' + mode, key, iv)
const cipher = createCipheriv(mode, key, iv)
return Buffer.concat([cipher.update(buffer), cipher.final()])
},
rsaEncrypt(buffer, key) {
@@ -203,8 +203,12 @@ contextBridge.exposeInMainWorld('lx', {
from(...args) {
return Buffer.from(...args)
},
bufToString(buf, format) {
return Buffer.from(buf, 'binary').toString(format)
},
},
},
version: '1.1.0',
// removeEvent(eventName, handler) {
// if (!eventNames.includes(eventName)) return Promise.reject(new Error('The event is not supported: ' + eventName))
// let handlers