Skip to content

Commit

Permalink
Fix code format
Browse files Browse the repository at this point in the history
  • Loading branch information
mryhryki committed Jul 30, 2023
1 parent e7e0f71 commit 919a72a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,24 @@ await Promise.all(Algorithms.map(async (alg) => {
}));

Deno.test("Compatibility (AES-CBC)", async (t) => {
const PlainData = "RMQc7sORwEpfXljFKRdp5mxlaAOvsndumTsAt3IvPLAb6L15hZ9wWX8pDkm9EHNE1dVsGvy01AiiOaVUltKKrK2SBJrtzhzywunE";
const EncryptData = "8c0310307c7928ac3d9a1dc54b18bc35e7f73e4d85c2f3271d53a38efafd19850171efb525060e860c0fe01cd363dad53573ed1c7dd01c3d845e5cd65017628e7ecfbf96449ad4c06f69d9e69d87afaf01a64875a4f48339973b60ca1493a7783ef9e1ee9f06c8270f41c6cb08d23959";
const Key = "b940fe16e9d74d4ad66686d6345b16db742279983af0a38f7fbfc3fcdb3195d8";
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);
});
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);
},
);
});
2 changes: 1 addition & 1 deletion src/test/01_flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const flow = async ({ encrypt, decrypt, alg, iv }: FlowArgs): Promise<void> => {
assert(encryptResult.iv, iv);
}

const {plainData} = await decrypt({ ...encryptResult, key: KEY });
const { plainData } = await decrypt({ ...encryptResult, key: KEY });
assert(
new TextDecoder().decode(plainData),
PlainData,
Expand Down

0 comments on commit 919a72a

Please sign in to comment.