ops.mjs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /* eslint no-console: 0 */
  2. /**
  3. * nodeApi.js
  4. *
  5. * Test node api operations
  6. *
  7. * Aim of these tests is to ensure each arg type is
  8. * handled correctly by the wrapper.
  9. *
  10. * @author d98762625 [d98762625@gmail.com]
  11. * @copyright Crown Copyright 2018
  12. * @license Apache-2.0
  13. */
  14. import assert from "assert";
  15. import it from "../assertionHandler";
  16. import {
  17. addLineNumbers,
  18. adler32Checksum,
  19. AESDecrypt,
  20. affineCipherDecode,
  21. affineCipherEncode,
  22. bifidCipherEncode,
  23. bitShiftRight,
  24. cartesianProduct,
  25. CSSMinify,
  26. toBase64,
  27. toHex,
  28. } from "../../../src/node/index";
  29. import chef from "../../../src/node/index";
  30. import TestRegister from "../../TestRegister";
  31. TestRegister.addApiTests([
  32. it("ADD: toggleString argument", () => {
  33. const result = chef.ADD("sample input", {
  34. key: {
  35. string: "some key",
  36. option: "Hex"
  37. }
  38. });
  39. assert.equal(result.toString(), "aO[^ZS\u000eW\\^cb");
  40. }),
  41. it("addLineNumbers: No arguments", () => {
  42. const result = addLineNumbers("sample input");
  43. assert.equal(result.toString(), "1 sample input");
  44. }),
  45. it("adler32Checksum: No args", () => {
  46. const result = adler32Checksum("sample input");
  47. assert.equal(result.toString(), "1f2304d3");
  48. }),
  49. it("AES decrypt: toggleString and option", () => {
  50. const result = AESDecrypt("812c34ae6af353244a63c6ce23b7c34286b60be28ea4645523d4494700e7", {
  51. key: {
  52. string: "some longer key1",
  53. option: "utf8",
  54. },
  55. iv: {
  56. string: "some iv",
  57. option: "utf8",
  58. },
  59. mode: "OFB",
  60. });
  61. assert.equal(result.toString(), "a slightly longer sampleinput?");
  62. }),
  63. it("AffineCipherDecode: number input", () => {
  64. const result = affineCipherDecode("some input", {
  65. a: 7,
  66. b: 4
  67. });
  68. assert.strictEqual(result.toString(), "cuqa ifjgr");
  69. }),
  70. it("affineCipherEncode: number input", () => {
  71. const result = affineCipherEncode("some input", {
  72. a: 11,
  73. b: 6
  74. });
  75. assert.strictEqual(result.toString(), "weiy qtpsh");
  76. }),
  77. it("analyzeHash", () => {
  78. const result = chef.analyseHash(chef.MD5("some input"));
  79. const expected = `Hash length: 32
  80. Byte length: 16
  81. Bit length: 128
  82. Based on the length, this hash could have been generated by one of the following hashing functions:
  83. MD5
  84. MD4
  85. MD2
  86. HAVAL-128
  87. RIPEMD-128
  88. Snefru
  89. Tiger-128`;
  90. assert.strictEqual(result.toString(), expected);
  91. }),
  92. it("AND", () => {
  93. const result = chef.AND("Scot-free", {
  94. key: "Raining Cats and Dogs",
  95. });
  96. assert.strictEqual(result.toString(), ".\"M$(D E.");
  97. }),
  98. it("atBash Cipher", () => {
  99. const result = chef.atbashCipher("Happy as a Clam");
  100. assert.strictEqual(result.toString(), "Szkkb zh z Xozn");
  101. }),
  102. it("Bcrypt", () => {
  103. const result = chef.bcrypt("Put a Sock In It");
  104. assert.strictEqual(result.toString(), "$2a$10$ODeP1.6fMsb.ENk2ngPUCO7qTGVPyHA9TqDVcyupyed8FjsiF65L6");
  105. }),
  106. it("bcryptCompare", () => {
  107. const result = chef.bcryptCompare("Put a Sock In It", {
  108. hash: "$2a$10$2rT4a3XnIecBsd1H33dMTuyYE1HJ1n9F.V2rjQtAH73rh1qvOf/ae",
  109. });
  110. assert.strictEqual(result.toString(), "Match: Put a Sock In It");
  111. }),
  112. it("Bcrypt Parse", () => {
  113. const result = chef.bcryptParse("$2a$10$ODeP1.6fMsb.ENk2ngPUCO7qTGVPyHA9TqDVcyupyed8FjsiF65L6");
  114. const expected = `Rounds: 10
  115. Salt: $2a$10$ODeP1.6fMsb.ENk2ngPUCO
  116. Password hash: 7qTGVPyHA9TqDVcyupyed8FjsiF65L6
  117. Full hash: $2a$10$ODeP1.6fMsb.ENk2ngPUCO7qTGVPyHA9TqDVcyupyed8FjsiF65L6`;
  118. assert.strictEqual(result.toString(), expected);
  119. }),
  120. it("bifid cipher decode", () => {
  121. const result = chef.bifidCipherDecode("Vhef Qnte Ke Xfhz Mxon Bmgf", {
  122. keyword: "Alpha",
  123. });
  124. assert.strictEqual(result.toString(), "What Goes Up Must Come Down");
  125. }),
  126. it("bifid cipher encode: string option", () => {
  127. const result = bifidCipherEncode("some input", {
  128. keyword: "mykeyword",
  129. });
  130. assert.strictEqual(result.toString(), "nmhs zmsdo");
  131. }),
  132. it("bit shift left", () => {
  133. const result = chef.bitShiftLeft("Keep Your Eyes Peeled");
  134. assert.strictEqual(result.toString(), ".ÊÊà@²Þêä@.òÊæ@ ÊÊØÊÈ");
  135. }),
  136. it("bitShiftRight: number and option", () => {
  137. const result = bitShiftRight("some bits to shift", {
  138. type: "Arithmetic shift",
  139. amount: 1,
  140. });
  141. assert.strictEqual(result.toString(), "9762\u001014:9\u0010:7\u00109443:");
  142. }),
  143. it("Blowfish encrypt", () => {
  144. const result = chef.blowfishEncrypt("Fool's Gold", {
  145. key: {
  146. string: "One",
  147. option: "hex",
  148. },
  149. iv: {
  150. string: "Two",
  151. option: "utf8"
  152. }
  153. });
  154. assert.strictEqual(result.toString(), "8999b513bf2ff064b2977dea7e05f1b5");
  155. }),
  156. it("Blowfish decrypt", () => {
  157. const result = chef.blowfishDecrypt("8999b513bf2ff064b2977dea7e05f1b5", {
  158. key: {
  159. string: "One",
  160. option: "hex",
  161. },
  162. iv: {
  163. string: "Two",
  164. option: "utf8",
  165. }
  166. });
  167. assert.strictEqual(result.toString(), "Fool's Gold");
  168. }),
  169. it("BSON Deserialise", () => {
  170. const result = chef.BSONDeserialise("....phrase.....Mouth-watering..");
  171. assert.strictEqual(result.toString(), "{\"phrase\": \"Mouth-watering\"}");
  172. }),
  173. it("BSON Serialise", () => {
  174. const result = chef.BSONSerialise({"phrase": "Mouth-watering"});
  175. assert.strictEqual(result.toString(), " ....phrase.....Mouth-watering..");
  176. }),
  177. it("Bzip2 Decompress", () => {
  178. const result = chef.bzip2Decompress(chef.fromBase64("QlpoOTFBWSZTWUdQlt0AAAIVgEAAAQAmJAwAIAAxBkxA0A2pTL6U2CozxdyRThQkEdQlt0A="));
  179. assert.strictEqual(result.toString(), "Fit as a Fiddle");
  180. }),
  181. it("cartesianProduct: binary string", () => {
  182. const result = cartesianProduct("1:2\\n\\n3:4", {
  183. itemDelimiter: ":",
  184. });
  185. assert.strictEqual(result.toString(), "(1,3):(1,4):(2,3):(2,4)");
  186. }),
  187. it("Change IP format", () => {
  188. const result = chef.changeIPFormat("172.20.23.54", {
  189. inputFormat: "Dotted Decimal",
  190. outputFormat: "Hex",
  191. });
  192. assert.strictEqual(result.toString(), "ac141736");
  193. }),
  194. it("Chi square", () => {
  195. const result = chef.chiSquare("Burst Your Bubble");
  196. assert.strictEqual(result.toString(), "433.55399816176475");
  197. }),
  198. it("Compare CTPH Hashes", () => {
  199. const result = chef.compareCTPHHashes("1234\n3456");
  200. assert.strictEqual(result.toString(), "0");
  201. }),
  202. it("Compare SSDEEPHashes", () => {
  203. const result = chef.compareCTPHHashes("1234\n3456");
  204. assert.strictEqual(result.toString(), "0");
  205. }),
  206. it("Convert area", () => {
  207. const result = chef.convertArea("12345", {
  208. inputUnits: "Square metre (sq m)",
  209. outputUnits: "Isle of Wight"
  210. });
  211. assert.strictEqual(result.toString(), "0.00003248684210526316");
  212. }),
  213. it("Convert data units", () => {
  214. const result = chef.convertDataUnits("12345", {
  215. inputUnits: "Bits (b)",
  216. outputUnits: "Kilobytes (KB)",
  217. });
  218. assert.strictEqual(result.toString(), "1.543125");
  219. }),
  220. it("Convert distance", () => {
  221. const result = chef.convertDistance("1234567", {
  222. inputUnits: "Nanometres (nm)",
  223. outputUnits: "Furlongs (fur)",
  224. });
  225. assert.strictEqual(result.toString(), "0.00000613699494949495");
  226. }),
  227. it("Convert mass", () => {
  228. const result = chef.convertMass("123", {
  229. inputUnits: "Earth mass (M⊕)",
  230. outputUnits: "Great Pyramid of Giza (6,000,000 tonnes)",
  231. });
  232. assert.strictEqual(result.toString(), "122429895000000000");
  233. }),
  234. it("Convert speed", () => {
  235. const result = chef.convertSpeed("123", {
  236. inputUnits: "Lunar escape velocity",
  237. outputUnits: "Jet airliner cruising speed",
  238. });
  239. assert.strictEqual(result.toString(), "1168.5");
  240. }),
  241. it("Count occurrences", () => {
  242. const result = chef.countOccurrences("Talk the Talk", {
  243. searchString: {
  244. string: "Tal",
  245. option: "Simple string",
  246. }
  247. });
  248. assert.strictEqual(result.toString(), "2");
  249. }),
  250. it("CRC16 Checksum", () => {
  251. const result = chef.CRC16Checksum("Rain on Your Parade");
  252. assert.strictEqual(result.toString(), "db1c");
  253. }),
  254. it("CRC32 Checksum", () => {
  255. const result = chef.CRC32Checksum("Rain on Your Parade");
  256. assert.strictEqual(result.toString(), "e902f76c");
  257. }),
  258. it("CSS Beautify", () => {
  259. const result = chef.CSSBeautify("header {color:black;padding:3rem;}");
  260. const expected = `header {
  261. \\tcolor:black;
  262. \\tpadding:3rem;
  263. }
  264. `;
  265. assert.strictEqual(result.toString(), expected);
  266. }),
  267. it("CSS minify: boolean", () => {
  268. const input = `header {
  269. // comment
  270. width: 100%;
  271. color: white;
  272. }`;
  273. const result = CSSMinify(input, {
  274. preserveComments: true,
  275. });
  276. assert.strictEqual(result.toString(), "header {// comment width: 100%;color: white;}");
  277. }),
  278. it("CSS Selector", () => {
  279. const result = chef.CSSSelector("<html><header><h1>Hello</h1></header></html>", {
  280. cssSelector: "h1",
  281. });
  282. assert.strictEqual(result.toString(), "<h1>Hello</h1>");
  283. }),
  284. it("CTPH", () => {
  285. const result = chef.CTPH("If You Can't Stand the Heat, Get Out of the Kitchen");
  286. assert.strictEqual(result.toString(), "A:+EgFgBKAA0V0UFfClEs6:+Qk0gUFse");
  287. }),
  288. it("Decode NetBIOS Name", () => {
  289. assert.strictEqual(chef.decodeNetBIOSName("EBGMGMCAEHHCGFGFGLCAFEGPCAENGFCA").toString(), "All Greek To Me");
  290. }),
  291. it("Decode text", () => {
  292. const encoded = chef.encodeText("Ugly Duckling", {
  293. encoding: "UTF16LE (1200)",
  294. });
  295. const result = chef.decodeText(encoded, {
  296. encoding: "UTF16LE (1200)",
  297. });
  298. assert.strictEqual(result.toString(), "Ugly Duckling");
  299. }),
  300. it("Derive EVP Key", () => {
  301. const result = chef.deriveEVPKey("", {
  302. passphrase: {
  303. string: "46 6c 65 61 20 4d 61 72 6b 65 74",
  304. option: "Hex",
  305. },
  306. salt: {
  307. string: "Market",
  308. option: "Hex",
  309. },
  310. });
  311. assert.strictEqual(result.toString(), "7c21a9f5063a4d62fb1050068245c181");
  312. }),
  313. it("Derive PBKDF2 Key", () => {
  314. const result = chef.derivePBKDF2Key("", {
  315. passphrase: {
  316. string: "Jack of All Trades Master of None",
  317. option: "utf8",
  318. },
  319. keySize: 256,
  320. iterations: 2,
  321. hashingFunction: "md5",
  322. salt: {
  323. string: "fruit",
  324. option: "utf8"
  325. }
  326. });
  327. assert.strictEqual(result.toString(), "728a885b209e8b19cbd7430ca32608ff09190f7ccb7ded204e1d4c50f87c47bf");
  328. }),
  329. it("DES Decrypt", () => {
  330. const result = chef.DESDecrypt("713081c66db781c323965ba8f166fd8c230c3bb48504a913", {
  331. key: {
  332. string: "onetwoth",
  333. option: "utf8",
  334. },
  335. iv: {
  336. string: "threetwo",
  337. option: "Hex",
  338. },
  339. mode: "ECB",
  340. });
  341. assert.strictEqual(result.toString(), "Put a Sock In It");
  342. }),
  343. it("DES Encrypt", () => {
  344. const result = chef.DESEncrypt("Put a Sock In It", {
  345. key: {
  346. string: "onetwoth",
  347. option: "utf8",
  348. },
  349. iv: {
  350. string: "threetwo",
  351. option: "Hex",
  352. },
  353. mode: "ECB",
  354. });
  355. assert.strictEqual(result.toString(), "713081c66db781c323965ba8f166fd8c230c3bb48504a913");
  356. }),
  357. it("Diff", () => {
  358. const result = chef.diff("one two\\n\\none two three");
  359. assert.strictEqual(result.toString(), "one two three");
  360. }),
  361. it("Disassemble x86", () => {
  362. const result = chef.disassembleX86(chef.toBase64("one two three"));
  363. const expected = `0000000000000000 0000 ADD BYTE PTR [RAX],AL\r
  364. 0000000000000002 0B250000000B OR ESP,DWORD PTR [000000000B000008]\r
  365. `;
  366. assert.strictEqual(result.toString(), expected);
  367. }),
  368. it("Divide", () => {
  369. assert.strictEqual(chef.divide("4\n7").toString(), "0.57142857142857142857");
  370. }),
  371. it("Drop bytes", () => {
  372. assert.strictEqual(chef.dropBytes("There's No I in Team").toString(), "'s No I in Team");
  373. }),
  374. it("Entropy", () => {
  375. const result = chef.entropy("Ride Him, Cowboy!");
  376. assert.strictEqual(result.toString(), "3.734521664779752");
  377. }),
  378. it("Escape string", () => {
  379. const result = chef.escapeString("Know the Ropes", {
  380. escapeLevel: "Everything",
  381. JSONCompatible: false,
  382. ES6Compatible: true,
  383. uppercaseHex: true,
  384. });
  385. assert.strictEqual(result.toString(), "\\x4B\\x6E\\x6F\\x77\\x20\\x74\\x68\\x65\\x20\\x52\\x6F\\x70\\x65\\x73");
  386. }),
  387. it("Escape unicode characters", () => {
  388. assert.strictEqual(chef.escapeUnicodeCharacters("σου").toString(), "\\u03C3\\u03BF\\u03C5");
  389. }),
  390. it("Expand alphabet range", () => {
  391. assert.strictEqual(
  392. chef.expandAlphabetRange("Fight Fire With Fire", {delimiter: "t"}).toString(),
  393. "Ftitgthttt tFtitrtet tWtitttht tFtitrte");
  394. }),
  395. it("Extract dates", () => {
  396. assert.strictEqual(chef.extractDates("Don't Look a Gift Horse In The Mouth 01/02/1992").toString(), "01/02/1992\n");
  397. }),
  398. it("Filter", () => {
  399. const result = chef.filter(
  400. `I Smell a Rat
  401. Every Cloud Has a Silver Lining
  402. Top Drawer`, {
  403. regex: "Every",
  404. });
  405. const expected = "Every Cloud Has a Silver Lining";
  406. assert.strictEqual(result.toString(), expected);
  407. }),
  408. it("Find / Replace", () => {
  409. assert.strictEqual(
  410. chef.findReplace(
  411. "Curiosity Killed The Cat",
  412. {
  413. find: {
  414. string: "l",
  415. option: "Regex",
  416. },
  417. replace: "s",
  418. }).toString(),
  419. "Curiosity Kissed The Cat");
  420. }),
  421. it("Fletcher8 Checksum", () => {
  422. assert.strictEqual(chef.fletcher8Checksum("Keep Your Eyes Peeled").toString(), "48");
  423. }),
  424. it("Format MAC addresses", () => {
  425. const result = chef.formatMACAddresses("00-01-02-03-04-05");
  426. const expected = `000102030405
  427. 000102030405
  428. 00-01-02-03-04-05
  429. 00-01-02-03-04-05
  430. 00:01:02:03:04:05
  431. 00:01:02:03:04:05
  432. `;
  433. assert.strictEqual(result.toString(), expected);
  434. }),
  435. it("Frequency distribution", () => {
  436. const result = chef.frequencyDistribution("Don't Count Your Chickens Before They Hatch");
  437. const expected = "{\"dataLength\":43,\"percentages\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13.953488372093023,0,0,0,0,0,0,2.3255813953488373,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2.3255813953488373,4.651162790697675,2.3255813953488373,0,0,0,2.3255813953488373,0,0,0,0,0,0,0,0,0,0,0,2.3255813953488373,0,0,0,0,2.3255813953488373,0,0,0,0,0,0,0,2.3255813953488373,0,4.651162790697675,0,9.30232558139535,2.3255813953488373,0,6.976744186046512,2.3255813953488373,0,2.3255813953488373,0,0,6.976744186046512,9.30232558139535,0,0,4.651162790697675,2.3255813953488373,6.976744186046512,4.651162790697675,0,0,0,2.3255813953488373,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"distribution\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,2,0,4,1,0,3,1,0,1,0,0,3,4,0,0,2,1,3,2,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"bytesRepresented\":22}";
  438. assert.strictEqual(result.toString(), expected);
  439. }),
  440. it("From base", () => {
  441. assert.strictEqual(chef.fromBase("11", {radix: 13}).toString(), "14");
  442. }),
  443. it("From BCD", () => {
  444. assert.strictEqual(chef.fromBCD("1143", { inputFormat: "Raw", scheme: "7 4 2 1"}).toString(), "31313433");
  445. }),
  446. it("From binary", () => {
  447. assert.strictEqual(chef.fromBinary("010101011100101101011010").toString(), "UËZ");
  448. }),
  449. it("From Charcode", () => {
  450. assert.strictEqual(chef.fromCharcode("4c 6f 6e 67 20 49 6e 20 54 68 65 20 54 6f 6f 74 68 0a").toString(), "Long In The Tooth\n");
  451. }),
  452. it("From decimal", () => {
  453. assert.strictEqual(chef.fromDecimal("72 101 108 108 111").toString(), "Hello");
  454. }),
  455. it("From hex", () => {
  456. assert.strictEqual(chef.fromHex("52 69 6e 67 20 41 6e 79 20 42 65 6c 6c 73 3f").toString(), "Ring Any Bells?");
  457. }),
  458. it("From hex content", () => {
  459. assert.strictEqual(chef.fromHexContent("foo|3d|bar").toString(), "foo=bar");
  460. }),
  461. it("To and From hex dump", () => {
  462. assert.strictEqual(chef.fromHexdump(chef.toHexdump("Elephant in the Room")).toString(), "Elephant in the Room");
  463. }),
  464. it("From HTML entity", () => {
  465. assert.strictEqual(chef.fromHTMLEntity("&amp;").toString(), "&");
  466. }),
  467. it("To and From morse code", () => {
  468. assert.strictEqual(chef.fromMorseCode(chef.toMorseCode("Put a Sock In It")).toString(), "PUT A SOCK IN IT");
  469. }),
  470. it("From octal", () => {
  471. assert.strictEqual(chef.fromOctal("113 156 157 167 40 164 150 145 40 122 157 160 145 163").toString(), "Know the Ropes");
  472. }),
  473. it("To, From punycode", () => {
  474. assert.strictEqual(chef.fromPunycode(chef.toPunycode("münchen")).toString(), "münchen");
  475. }),
  476. it("From unix timestamp", () => {
  477. assert.strictEqual(chef.fromUNIXTimestamp("978346800").toString(), "Mon 1 January 2001 11:00:00 UTC");
  478. }),
  479. it("toBase64: editableOption", () => {
  480. const result = toBase64("some input", {
  481. alphabet: {
  482. value: "0-9A-W"
  483. },
  484. });
  485. assert.strictEqual(result.toString(), "SPI1R1T0");
  486. }),
  487. it("toBase64: editableOptions key is value", () => {
  488. const result = toBase64("some input", {
  489. alphabet: "0-9A-W",
  490. });
  491. assert.strictEqual(result.toString(), "SPI1R1T0");
  492. }),
  493. it("toBase64: editableOptions default", () => {
  494. const result = toBase64("some input");
  495. assert.strictEqual(result.toString(), "c29tZSBpbnB1dA==");
  496. }),
  497. it("toHex: accepts args", () => {
  498. const result = toHex("some input", {
  499. delimiter: "Colon",
  500. });
  501. assert.strictEqual(result.toString(), "73:6f:6d:65:20:69:6e:70:75:74");
  502. }),
  503. ]);