Ciphers.mjs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * Cipher tests.
  3. *
  4. * @author Matt C [matt@artemisbot.uk]
  5. * @author n1474335 [n1474335@gmail.com]
  6. *
  7. * @copyright Crown Copyright 2018
  8. * @license Apache-2.0
  9. */
  10. import TestRegister from "../../TestRegister";
  11. TestRegister.addTests([
  12. {
  13. name: "Affine Encode: no input",
  14. input: "",
  15. expectedOutput: "",
  16. recipeConfig: [
  17. {
  18. op: "Affine Cipher Encode",
  19. args: [1, 0]
  20. }
  21. ],
  22. },
  23. {
  24. name: "Affine Encode: no effect",
  25. input: "some keys are shaped as locks. index[me]",
  26. expectedOutput: "some keys are shaped as locks. index[me]",
  27. recipeConfig: [
  28. {
  29. op: "Affine Cipher Encode",
  30. args: [1, 0]
  31. }
  32. ],
  33. },
  34. {
  35. name: "Affine Encode: normal",
  36. input: "some keys are shaped as locks. index[me]",
  37. expectedOutput: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
  38. recipeConfig: [
  39. {
  40. op: "Affine Cipher Encode",
  41. args: [23, 23]
  42. }
  43. ],
  44. },
  45. {
  46. name: "Affine Decode: no input",
  47. input: "",
  48. expectedOutput: "",
  49. recipeConfig: [
  50. {
  51. op: "Affine Cipher Decode",
  52. args: [1, 0]
  53. }
  54. ],
  55. },
  56. {
  57. name: "Affine Decode: no effect",
  58. input: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
  59. expectedOutput: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
  60. recipeConfig: [
  61. {
  62. op: "Affine Cipher Decode",
  63. args: [1, 0]
  64. }
  65. ],
  66. },
  67. {
  68. name: "Affine Decode: normal",
  69. input: "vhnl tldv xyl vcxelo xv qhrtv. zkolg[nl]",
  70. expectedOutput: "some keys are shaped as locks. index[me]",
  71. recipeConfig: [
  72. {
  73. op: "Affine Cipher Decode",
  74. args: [23, 23]
  75. }
  76. ],
  77. },
  78. {
  79. name: "Atbash: no input",
  80. input: "",
  81. expectedOutput: "",
  82. recipeConfig: [
  83. {
  84. op: "Atbash Cipher",
  85. args: []
  86. }
  87. ],
  88. },
  89. {
  90. name: "Atbash: normal",
  91. input: "old slow slim horn",
  92. expectedOutput: "low hold horn slim",
  93. recipeConfig: [
  94. {
  95. op: "Atbash Cipher",
  96. args: []
  97. }
  98. ],
  99. },
  100. {
  101. name: "Bifid Cipher Encode: no input",
  102. input: "",
  103. expectedOutput: "",
  104. recipeConfig: [
  105. {
  106. "op": "Bifid Cipher Encode",
  107. "args": ["nothing"]
  108. }
  109. ],
  110. },
  111. {
  112. name: "Bifid Cipher Encode: no key",
  113. input: "We recreate conditions similar to the Van-Allen radiation belt in our secure facilities.",
  114. expectedOutput: "Vq daqcliho rmltofvlnc qbdhlcr nt qdq Fbm-Rdkkm vuoottnoi aitp al axf tdtmvt owppkaodtx.",
  115. recipeConfig: [
  116. {
  117. "op": "Bifid Cipher Encode",
  118. "args": [""]
  119. }
  120. ],
  121. },
  122. {
  123. name: "Bifid Cipher Encode: normal",
  124. input: "We recreate conditions similar to the Van-Allen radiation belt in our secure facilities.",
  125. expectedOutput: "Wc snpsigdd cpfrrcxnfi hikdnnp dm crc Fcb-Pdeug vueageacc vtyl sa zxm crebzp lyoeuaiwpv.",
  126. recipeConfig: [
  127. {
  128. "op": "Bifid Cipher Encode",
  129. "args": ["Schrodinger"]
  130. }
  131. ],
  132. },
  133. {
  134. name: "Bifid Cipher Decode: no input",
  135. input: "",
  136. expectedOutput: "",
  137. recipeConfig: [
  138. {
  139. "op": "Bifid Cipher Decode",
  140. "args": ["nothing"]
  141. }
  142. ],
  143. },
  144. {
  145. name: "Bifid Cipher Decode: no key",
  146. input: "Vq daqcliho rmltofvlnc qbdhlcr nt qdq Fbm-Rdkkm vuoottnoi aitp al axf tdtmvt owppkaodtx.",
  147. expectedOutput: "We recreate conditions similar to the Van-Allen radiation belt in our secure facilities.",
  148. recipeConfig: [
  149. {
  150. "op": "Bifid Cipher Decode",
  151. "args": [""]
  152. }
  153. ],
  154. },
  155. {
  156. name: "Bifid Cipher Decode: normal",
  157. input: "Wc snpsigdd cpfrrcxnfi hikdnnp dm crc Fcb-Pdeug vueageacc vtyl sa zxm crebzp lyoeuaiwpv.",
  158. expectedOutput: "We recreate conditions similar to the Van-Allen radiation belt in our secure facilities.",
  159. recipeConfig: [
  160. {
  161. "op": "Bifid Cipher Decode",
  162. "args": ["Schrodinger"]
  163. }
  164. ],
  165. },
  166. ]);