officecrypto-tool
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -22,3 +22,3 @@ /* eslint-disable valid-jsdoc */ | ||
// This is an ArrayBuffer in the browser. Convert to a Buffer. | ||
if (ArrayBuffer.isView(input)) { | ||
if (ArrayBuffer.isView(input) || input instanceof ArrayBuffer) { | ||
input = Buffer.from(input); | ||
@@ -100,3 +100,3 @@ } else { | ||
// This is an ArrayBuffer in the browser. Convert to a Buffer. | ||
if (ArrayBuffer.isView(input)) { | ||
if (ArrayBuffer.isView(input) || input instanceof ArrayBuffer) { | ||
input = Buffer.from(input); | ||
@@ -132,3 +132,3 @@ } else { | ||
// This is an ArrayBuffer in the browser. Convert to a Buffer. | ||
if (ArrayBuffer.isView(input)) { | ||
if (ArrayBuffer.isView(input) || input instanceof ArrayBuffer) { | ||
input = Buffer.from(input); | ||
@@ -135,0 +135,0 @@ } else { |
@@ -200,2 +200,1 @@ /* eslint-disable linebreak-style */ | ||
}; | ||
{ | ||
"name": "officecrypto-tool", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "officeCrypto is a library for node.js that can be used to decrypt and encrypt excel files.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -20,2 +20,26 @@ | ||
}); | ||
it('agile decrypt, input is ArrayBuffer', async () => { | ||
try { | ||
const input = await fs.readFile(`${filePath}/agile_pass_test.xlsx`); | ||
const arrayBuffer = input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength); | ||
const output = await officeCrypto.decrypt(arrayBuffer, {password: '123456'}); | ||
await fs.writeFile(`${filePath}/agile_out_success.xlsx`, output); | ||
expect(200).toEqual(200); | ||
} catch (error) { | ||
throw error; | ||
} | ||
}); | ||
it('agile decrypt, input is TypeBuffer', async () => { | ||
try { | ||
const input = await fs.readFile(`${filePath}/agile_pass_test.xlsx`); | ||
const typeBuffer = new Uint8Array(input); | ||
const output = await officeCrypto.decrypt(typeBuffer, {password: '123456'}); | ||
await fs.writeFile(`${filePath}/agile_out_success.xlsx`, output); | ||
expect(200).toEqual(200); | ||
} catch (error) { | ||
throw error; | ||
} | ||
}); | ||
}); |
@@ -17,2 +17,18 @@ | ||
it('encrypt success, input is ArrayBuffer', async () => { | ||
const input = await fs.readFile(`${filePath}/agile_input_test.xlsx`); | ||
const arrayBuffer = input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength); | ||
const output = officeCrypto.encrypt(arrayBuffer, {password: '123456'}); | ||
await fs.writeFile(`${filePath}/agile_pass_out_success_arraybuffer.xlsx`, output); | ||
// expect(200).toEqual(200); | ||
}); | ||
it('encrypt success, input is TypeBuffer', async () => { | ||
const input = await fs.readFile(`${filePath}/agile_input_test.xlsx`); | ||
const typeBuffer = new Uint8Array(input); | ||
const output = officeCrypto.encrypt(typeBuffer, {password: '123456'}); | ||
await fs.writeFile(`${filePath}/agile_pass_out_success_typeBuffer.xlsx`, output); | ||
// expect(200).toEqual(200); | ||
}); | ||
it('encrypt failure. The password length is 256, The maximum password length is 255', async () => { | ||
@@ -19,0 +35,0 @@ const test = function test() { |
@@ -17,2 +17,16 @@ | ||
it('ecma376_agile: The file is encrypted. Input is ArrayBuffer', async () => { | ||
const input = await fs.readFile(`${decryptFilePath}/agile_pass_test.xlsx`); | ||
const arrayBuffer = input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength); | ||
const isEncrypted = officeCrypto.isEncrypted(arrayBuffer); | ||
expect(isEncrypted).toEqual(true); | ||
}); | ||
it('ecma376_agile: The file is encrypted. Input is TypeBuffer', async () => { | ||
const input = await fs.readFile(`${decryptFilePath}/agile_pass_test.xlsx`); | ||
const typeBuffer = new Uint8Array(input); | ||
const isEncrypted = officeCrypto.isEncrypted(typeBuffer); | ||
expect(isEncrypted).toEqual(true); | ||
}); | ||
it('ecma376_agile: The file is not encrypted.', async () => { | ||
@@ -19,0 +33,0 @@ const input = await fs.readFile(`${encryptFilePath}/agile_input_test.xlsx`); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
801604
3103