diff --git a/components/Kryptos/Step/Base.vue b/components/Kryptos/Step/Base.vue index 1f63ce0..09a2719 100644 --- a/components/Kryptos/Step/Base.vue +++ b/components/Kryptos/Step/Base.vue @@ -3,6 +3,7 @@ import KryptosStepVigenere from './Vigenere.vue'; import KryptosStepRotate from './Rotate.vue'; import KryptosStepReverse from './Reverse.vue'; import KryptosStepPad from './Pad.vue'; +import KryptosStepJump from './Jump.vue'; const emit = defineEmits(['change', 'remove']); @@ -23,7 +24,8 @@ const modes = [ KryptosStepVigenere, KryptosStepRotate, KryptosStepReverse, - KryptosStepPad + KryptosStepPad, + KryptosStepJump ]; diff --git a/components/Kryptos/Step/Jump.vue b/components/Kryptos/Step/Jump.vue new file mode 100644 index 0000000..e9d80d4 --- /dev/null +++ b/components/Kryptos/Step/Jump.vue @@ -0,0 +1,24 @@ + + + diff --git a/components/Kryptos/Step/Mode.vue b/components/Kryptos/Step/Mode.vue index ad9345d..3827a14 100644 --- a/components/Kryptos/Step/Mode.vue +++ b/components/Kryptos/Step/Mode.vue @@ -8,6 +8,7 @@ const model = defineModel(); + diff --git a/composables/index.ts b/composables/index.ts index 4fa3704..2892aef 100644 --- a/composables/index.ts +++ b/composables/index.ts @@ -2,3 +2,4 @@ export { useVigenere } from './kryptos/use-vigenere.ts'; export { useRotate } from './kryptos/use-rotate.ts'; export { useReverse } from './kryptos/use-reverse.ts'; export { usePad } from './kryptos/use-pad.ts'; +export { useJump } from './kryptos/use-jump.ts'; diff --git a/composables/kryptos/use-jump.ts b/composables/kryptos/use-jump.ts new file mode 100644 index 0000000..623d923 --- /dev/null +++ b/composables/kryptos/use-jump.ts @@ -0,0 +1,24 @@ +export const useJump = (cipher, jump, shift) => { + const result = ref(''); + + const decode = (cipher, jump, shift) => { + const text = cipher.split(''); + const result = []; + let x = shift - 1; + + for (let i = 0; i < text.length; i++) { + x = (x + jump) % text.length; + result.push(text[x]); + } + + return result.join(''); + }; + + const update = () => { + result.value = decode(toValue(cipher), toValue(jump), toValue(shift)); + }; + + watchEffect(update); + + return { result }; +};