E
E
Evgeny Babkin2015-09-10 19:44:48
JavaScript
Evgeny Babkin, 2015-09-10 19:44:48

Give me an idea how to implement a Caesar cipher in JS?

It is necessary to implement a script that would encrypt the text using the Caesar Cipher (each letter of the text is shifted by +-n characters to the right / left relative to its position in the alphabet). I am just starting to program, so only one implementation idea was born - to receive a unicode character and shift accordingly.
My way of implementation seems to me govnokoda.
codepen.io/heyjoe/pen/wKKgeG
Please tell me other ways to implement this script.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg, 2015-09-10
@ptrvch

  1. Create a string containing the alphabet
    codepen.io/ptrvch/pen/VvvPdo

P
Pavel Volintsev, 2015-09-10
@copist

The idea is to make a list of all letters that can be converted.
If someone enters a string with characters outside of this list, such as hieroglyphs, then they will not be shifted, because they are not in the list.

R
Rafael™, 2015-09-10
@maxminimus

You distill the entire string into a letter-by-character array and iterate through its elements
For each character, set a condition check and replace the contents of the array element with the desired character
And reverse mirror decoding operation
But there is no cryptographic strength at all
Because there is a frequency of using characters in each language, it has its own

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question