Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
VrindavanSanap committed Feb 22, 2024
1 parent bde3062 commit 3d8aa2d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ for (let i = 0; i < chars.length; i++) {
itos[i] = ch;
}

export function ceaser_cipher(string, n = 0){
string = string.replace(/[^a-zA-Z]/g, '').toLowerCase();
export function ceaser_cipher(string, n = 0, keep_spaces = false){

string = string.replace(/[^a-zA-Z\s]/g, '').toLowerCase();
let result = "";
for (let i = 0; i < string.length; i++) {
let c = string[i];
if (c == " ") {
result += " "
continue
}
result += itos[(stoi[c] + n) % 26]
}
if (!keep_spaces) {
result = result.replace(/\s/g, '')
}
return result;
}
export function word_freq(string) {
Expand Down

0 comments on commit 3d8aa2d

Please sign in to comment.