Skip to content

Commit

Permalink
Add compatibility test for AES-CBC
Browse files Browse the repository at this point in the history
  • Loading branch information
mryhryki committed Jul 30, 2023
1 parent 29f1f91 commit e7e0f71
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ 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",
);
});
});
}));

// 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);
});
});

0 comments on commit e7e0f71

Please sign in to comment.