Polybius-Square-cipher | also called polybius checkerboard , which was a device | Encryption library
kandi X-RAY | Polybius-Square-cipher Summary
kandi X-RAY | Polybius-Square-cipher Summary
this cipher is also called polybius checkerboard,which was a device invented by the Ancient.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Polybius-Square-cipher
Polybius-Square-cipher Key Features
Polybius-Square-cipher Examples and Code Snippets
Community Discussions
Trending Discussions on Polybius-Square-cipher
QUESTION
I am working with ciphers; encrypting and decrypting and I'm currently working with the Polybius Cipher with the modern Latin alphabet. For example, the letters 'a' is the 2-digit code, '11' and 'abc' is '11 12 13'.
I have found a solution in Python:
...ANSWER
Answered 2021-Jan-03 at 17:55let row = letter.charCodeAt(i - letter.charCodeAt('a')) / 5 + 1;
is not correct since the char code of the letter itself is letter.charCodeAt(0)
and the char code of 'a'
is 'a'.charCodeAt(0)
. Moreover, you need to use Math.floor
to round down.
Thus, it should be let row = Math.floor((letter.charCodeAt(0) - 'a'.charCodeAt(0)) / 5) + 1;
.
There is a similar problem with the col
initialization and it should be let col = (letter.charCodeAt(0) - 'a'.charCodeAt(0)) % 5 + 1;
.
Next, to check if the letter is k
, there is no need to compare char codes, you can directly use letter === 'k'
. For the comparison to see if the letter is greater than or equal to 'j'
, a similar issue exists and you can directly use >= 'j'
.
Finally, you return in the first iteration of the loop, so it will only run once. Instead, you can build a string to output or return at the end.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Polybius-Square-cipher
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page