Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
VrindavanSanap committed Feb 18, 2024
1 parent f3e7c77 commit f19e0f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function ceaser_cipher(string, n = 0,is_case_sensitive, keep_spaces){
result += " "
continue
}
result += itos[(stoi[c] + n) % 52]
result += itos[(stoi[c] + n) % 26]
}
if (!is_case_sensitive) {
result = result.toLowerCase();
Expand Down
16 changes: 4 additions & 12 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,18 @@ export default function Home() {

function encrypted_messages(message) {
let enc_messages = [];
let score;
for (let i = 0; i < 26; i++) {
const encrypted = ceaser_cipher(message, i, is_case_sensitive, keep_spaces);
score = sentence_score(encrypted); // Limit to 2 decimal places
// console.log(score, lowest_score)
if (score < lowest_score) {
set_lowest_score(score)
set_most_likely_message(encrypted)
}
for (let i = 0; i < 52; i++) {
const encrypted = ceaser_cipher(message, i,is_case_sensitive,keep_spaces);
enc_messages.push(
<p key={i}>
+{i + " "}
{encrypted + " "}
{score}
</p>
);


}

return enc_messages
}
return (
Expand Down

0 comments on commit f19e0f7

Please sign in to comment.