const assert = require('assert');
const { decrypt } = require('..');
const key = '2bc7b15a8706ab48035990172e2b378cf62ef9b6282344d9009a112251cf522d';
describe('decrypt from node test cases', () => {
it('test data length = 1', () => {
const encrypted =
'0487ae2e351144105adc918808d6025bc809292101bb96b3cde33b9be9e83a4fc6b087609c832e42dcdfb909efc38dc542996f9fcac5006ea4d8fa0287bf784b30f5a0d50cfd4b23d8341f9ce5cfe76eaabd0cb9c1bccc7cd30f5a3b7e5146fa62e2b3be181100df8aaa67c136c75a707498';
assert.equal(decrypt(key, encrypted).toString('hex'), '52');
});
it('test data length = 5', () => {
const encrypted =
'0451cf9b25b24bcb54843c8f259874ca5289c1e7686f6f9f7629787383530a3761b8a34a0c3626a06c11caf7d810106ef0fe7c01128b436cafebd69a98d0bcbe0e2a8326cc82543902a134f070d80e5f6983085f40c97140e623c83409fefccb5e45988373f451460595a2209c8329395dad87b25c93';
assert.equal(decrypt(key, encrypted).toString('hex'), 'fdfc072182');
});
it('test data length = 10', () => {
const encrypted =
'0443e2e48689a74d436050518d4144728d245c59e70128342bf2097eedecb7e0805ca0789351de06ac211fc4d5dea6c8dd6e96b3076813364602715c9597e708496139e9ac6d4b3053d95797196abfb896ba53c9425c63edffde600fd003a6af6b6d57aaa453df8c99700254265cff60507c01e8eff53ab8360f7e';
assert.equal(
decrypt(key, encrypted).toString('hex'),
'654f163f5f0f9a621d72'
);
});
it('test data length = 100', () => {
const encrypted =
'04a1e9e4f3349b4d688f9d16ce54f8c3286d3860d0d09c80d065c05fd3353bf9bfc402e4d09415f5af47fbb908e9b6ab2711018443d82c0dbdd423419a40be23465e02807a90e66dcf708efddca4b330139fd1c1fb16a406036a6a6efd46991384d2d3bc6ff6bba9495ddcdb69d73cc0882d38563abed711abad1d0c4db6dea638ff94b3a6d10c46885054d0df5d94b1b5b9654827472c3ff74cd26a6253c5ece707d1213c96b3955849b47f36c1929df8031b2f763036084c0425d4a0f105db09399f476354923e50e88a6860bf9f791db57da67b';
assert.equal(
decrypt(key, encrypted).toString('hex'),
'9566c74d10037c4d7bbb0407d1e2c64981855ad8681d0d86d1e91e00167939cb6694d2c422acd208a0072939487f6999eb9d18a44784045d87f3c67cf22746e995af5a25367951baa2ff6cd471c483f15fb90badb37c5821b6d95526a41a9504680b4e7c'
);
});
it('test data length = 500', () => {
const encrypted =
'0402d3a31835054f7bef086f0e27be94bb7c7e42427b7b0ca018397463db08a533e610d701b535138f01038fa5393024e861dd6ee2e43e340d4e649beb22ee5f97c8db7ab464779301f256b7fd6f91d9db11630b2fe01236777902ea9b9a112d151ea9dfe409230bbb5cde43191e25432dacef4f8dbc02e7d91fd0c1d329f85a38911de4c825207da41e01d77b6eb3ffecddbcc270a2538e729e3eb777bf4b31461d9707db212af06b19baf8aa0f51b170a233e492157e2b133364ee7e75960c9c0379b3b7944166501854e678972ae3437e2dad04228bd77b04d909c5308fa5a4119cb9a41336dead7c800602cfdf4ed46d7eaec35cc7dc42cc39a0f8136a2b57d84a6730619b2af3e0d7df0fbe9d8bebc3c98cd38ff67d04b0d285474ec64863a73118fec707e4a1938d89a2c45a529c7ccc673a5f9ac96e24e453cff5c4d1c20bf37feccc3522e34f5b1f66d2d1e756180289bd517b0ce027215d9dceea3a15fcb77dc1076ca6b06839ba4b8674328e8db2193480261f50b15aa01b357a64f9556dc9e12e164194dadfee2a713df7be27ba3acdbf30a539afcd8c25b7f52aea8b090bb796fd6e74571f5101e8d94d7de470f1e0f6c6dba34ef4841acc6e5dfa606484988be5991b748a96c3fa27115260c0d5b42b37f9569c5ea379776f5371e9c79dc7a430f44cc96ae43f8292b486429cce83c693f5f2a7c05933104e60eb26661e60b487a919ae4d9eddc7a5c74f3185393effa0aa93027c92d0220e8f98a8874fc8825a44e07fff0860d76ac4d96bf2386abbe9f0864b91ec766b0e7c6b14624996bb2a100cd7fe5c0c93c6a7457c66caf61df9296ed400f1e6584e4f11fb9ddbca';
assert.equal(
decrypt(key, encrypted).toString('hex'),
'8b763a1b1d49d4955c8486216325253fec738dd7a9e28bf921119c160f0702448615bbda08313f6a8eb668d20bf5059875921e668a5bdf2c7fc4844592d2572bcd0668d2d6c52f5054e2d0836bf84c7174cb7476364cc3dbd968b0f7172ed85794bb358b0c3b525da1786f9fff094279db1944ebd7a19d0f7bbacbe0255aa5b7d44bec40f84c892b9bffd43629b0223beea5f4f74391f445d15afd4294040374f6924b98cbf8713f8d962d7c8d019192c24224e2cafccae3a61fb586b14323a6bc8f9e7df1d929333ff993933bea6f5b3af6de0374366c4719e43a1b067d89bc7f01f1f573981659a44ff17a4c7215a3b539eb1e5849c6077dbb5722f5717a289a266f97647981998ebea89c0b4b373970115e82ed6f4125c8fa7311e4d7defa922daae7786667f7e936cd4f24abf7df866baa56038367ad6145de1ee8f4a8b0993ebdf8883a0ad8be9c3978b04883e56a156a8de563afa467d49dec6a40e9a1d007f033c2823061bdd0eaa59f8e4da6430105220d0b29688b734b8ea0f3ca9936e8461f10d77c96ea80a7a665f606f6a63b7f3dfd2567c18979e4d60f26686d9bf2fb26c901ff354cde1607ee294b39f32b7c7822ba64f84ab43ca0c6e6b91c1fd3be8990434179d3af4491a369012db92d184fc39d1734ff5716428953bb6865fcf92b0c3a17c9028be9914eb7649c6c934780'
);
});
it('test data length = 100000', () => {
const encrypted =
'043bd44ad1ce0a824fc8dbfec4d412ffa87dca9b9e955eddefbac0227e68ebb209a65a98eabc1a65a757b4a09d112d2aa7548a401885cc4158c0f208be362e61f0a670a8a4b8cd88abf04cad833aa429872955ecd6623dbc18ccd1325ffbeab9d196ffc7d8675ace26646420308225dba020fd0b06d3473f23ec633eb83fbd73ac2a578077aa35647a90fe67170e6862523059378cc2e4e49d0d5a650f7b76361dc3d07b1ab38f70dd2e0a441e05cc69f8978f60f46a96af373d4955a78042d556a19cfde02717b36b555a7a724f42da1bea4887326148622766b824c91f98993cb389bb9e6e4611dc0629cbd8332404870ce1c0cb5123a4cedd7cc3e93c289780a863bb3f6f3ca2795e29c9058bca383e4100876e7ca9fa022b656de1967d461aa6ad3ec180c9fed2adaa3c9b40a26bb93205b22b1adb5fa0b697f8b8e2152298f09ac7e3ff2a3942e6b98b24fa938169cc3b2c1f600aeea989df5d35d3fec5411ad67e99bc2b4dacffc806fa9d161ac281a9c1f29d10266e7be7b4c4c50b3ebe1bcff4b684f835265ee3b3c0be4cd25dfd21d9e1a986553eed3949647a19ac1ff8ebe4c1c6034c17152564a5a707a6deea9802ae9e50b7e1060496f1441466a7f873a33bef13515a795e382f2e0d991df589ef299f5262f193473683e95b1b8f32c175c4587e332d3811a1c8367c024ae14e95216883c9ab09df1ae500dac04be89801c396035f1acc27cc803248f27a0b69339d35d5f5e742aeb0ee55d44e5373571ece7a3a5541000a514391b99795935615ad52662768957ab10159a01307a80f91df40cf44115ace37169068f8c3b5e166341e019698d88179dc8425ac321e7ad91975beefcc33daf4fbf62aac13d78c69af8096fd5fa726de92ca36ff36538d2904708a0171792c68e0c7e9fb7b269626a18c604dde699863784d0639d6ebf3ab0eec336aa9279959ea1e3d3f7cd6a5018ac9b1e3e99b906974976dd6c94d782ba4574ddc147b728bcb035c838c5b6c69536dba4ab043c345c5d01df5ad3da19c53d273f671690d0187249f16df6d22e9d8d1213f21f4127bf84d520821c9be2637022ba2d00076688964b0fb0eff5b8af31181a9270a291a3d4b8a433aee3643e60b62236d4eada96a940e8fe6f7620616a79a8244ab6e62adacf00df5aeabed52c761816501eb9f1b4e4a90b17bd2118f61c8e3c52491b3c1991009fa135bf519944510c7dc6db16f07df51a6fcef23f66d9fcc86836d4af816b46757992a4aff359b0ce254cae79f64cd444b7ff69fe9e6fc45b187af97ba5ef60b272ea29848d909fdcdf33b767a941f4f9982f3dcda36ea51f795d9433a17b431d0cc037185c309dd6d834213b4420e37742e76e69841be51482dba33ccc8b499147edbe8a688c997487e4d8a8e931d8f117fa27accf69a296dd965296f07acefa3b671ecf27b177dd6260da689139317b53e5271fc6385c2924c097286f876f4d201b4833275842f65d7c233d98e7f84a96dadbabac5c05b0a1d61a306300f63d5bd00be79fedc2207605536550115050b4ed16581d3e53dc33f80aa748affbdcb095f9af14a92ee277d910e18044cbcf047e1cde69c570a70988e7bb7ac481217da539234e0f0a0a4f491404e72aa0387f9b8766c70927fd4e127c0bd1733d0c92af1deb4d6edfad0ddec08ee7870519b9f4afe9514be794457b97165d57fa32083ff4b630ffb5c105f0d82d3da30d4d619cb2512253c736d93b22f8382d4fdc361804cb5a7edb2c6078e7580bf752dbb25b6c6787b4c8e9d689f7cbb12c23a22245891fe0b3d961952f67e37655f9f56e519e7ae081b9d6be0988bfcecaf4b8d9d08bb954ecab30b52c0cfab4e49013ae975b649312e6f820bd06d9b6f082f511618eb8e41d7b4c4c556eec509fef1d3ea4c5dc91fa87ab208616ce29cdd326a01b591181a13f0201deced9e6f1d60785d423afc37fddc4838d13683e2e0360d71ad9558920a3b1b2b544abb32ce03dce7bc2a442e63e1344f0e34146968f38bdc38ec8971c36d73b7d1f96efb09520643132f3e5c3ba5d80f263055cf9a26af6fa7eec14af6dfb6d29001693a7d3a0d4da68544328ee994862869b9a7770d1b3dc65a970a03c425f673f0b890d75b6a31b2f752db1272b6d6daf5babc90401343a5a5169e1e4de873da788265e5691866d433644485455df746cce7cd17ab13f342ba538207c940c7f03f46a82b2dd2f5cafa33e95f43a09692377f58a4ea24be4ef3d97797ef5897ea109707503958a70e19d2654e28e6935f6f6628f78fcb149dbd6562f00de6c9c5a8993462a67f12bb875c91b877780f0d96b7b4a