From e7e0f7184076c292f3fdfeaeeff91840583dd842 Mon Sep 17 00:00:00 2001 From: mryhryki Date: Sun, 30 Jul 2023 10:51:09 +0900 Subject: [PATCH] Add compatibility test for AES-CBC --- src/index.test.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/index.test.ts b/src/index.test.ts index 26cbf33..8057932 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -26,9 +26,9 @@ await Promise.all(Algorithms.map(async (alg) => { }); await t.step(`Decrypt: ${alg}`, async () => { - const decryptResult = await decrypt({ ...encryptResult, key }); + const { plainData } = await decrypt({ ...encryptResult, key }); assertEquals( - new TextDecoder().decode(decryptResult), + new TextDecoder().decode(plainData), sampleData, "decrypt result", ); @@ -36,14 +36,14 @@ await Promise.all(Algorithms.map(async (alg) => { }); })); -// Deno.test("Compatibility", async (t) => { -// const PlainData = "RMQc7sORwEpfXljFKRdp5mxlaAOvsndumTsAt3IvPLAb6L15hZ9wWX8pDkm9EHNE1dVsGvy01AiiOaVUltKKrK2SBJrtzhzywunE"; -// const EncryptData = "8c0310307c7928ac3d9a1dc54b18bc35e7f73e4d85c2f3271d53a38efafd19850171efb525060e860c0fe01cd363dad53573ed1c7dd01c3d845e5cd65017628e7ecfbf96449ad4c06f69d9e69d87afaf01a64875a4f48339973b60ca1493a7783ef9e1ee9f06c8270f41c6cb08d23959"; -// const Key = "b940fe16e9d74d4ad66686d6345b16db742279983af0a38f7fbfc3fcdb3195d8"; -// const IV = "55bb4e5f8996d0a9e6a8a62c5adcff5b"; -// -// await t.step(`printf '${PlainData}' | openssl aes-256-cbc -K "${Key}" -iv "${IV}" -nosalt | xxd -p`, async () => { -// const result = await encrypt({ alg: "AES-CBC", iv: IV, key: Key, plainData: PlainData }); -// assertEquals(result.data, EncryptData); -// }); -// }); +Deno.test("Compatibility (AES-CBC)", async (t) => { + const PlainData = "RMQc7sORwEpfXljFKRdp5mxlaAOvsndumTsAt3IvPLAb6L15hZ9wWX8pDkm9EHNE1dVsGvy01AiiOaVUltKKrK2SBJrtzhzywunE"; + const EncryptData = "8c0310307c7928ac3d9a1dc54b18bc35e7f73e4d85c2f3271d53a38efafd19850171efb525060e860c0fe01cd363dad53573ed1c7dd01c3d845e5cd65017628e7ecfbf96449ad4c06f69d9e69d87afaf01a64875a4f48339973b60ca1493a7783ef9e1ee9f06c8270f41c6cb08d23959"; + const Key = "b940fe16e9d74d4ad66686d6345b16db742279983af0a38f7fbfc3fcdb3195d8"; + const IV = "55bb4e5f8996d0a9e6a8a62c5adcff5b"; + + await t.step(`printf '${PlainData}' | openssl aes-256-cbc -K "${Key}" -iv "${IV}" -nosalt | xxd -p`, async () => { + const result = await encrypt({ alg: "AES-CBC", iv: IV, key: Key, plainData: new TextEncoder().encode(PlainData) }); + assertEquals(result.data, EncryptData); + }); +});