Skip to content

Commit

Permalink
add crypto outside pages
Browse files Browse the repository at this point in the history
  • Loading branch information
VrindavanSanap committed Dec 25, 2023
1 parent b496017 commit cab17d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crypto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const chars = "abcdefghijklmnopqrstuvwxyz";

export const stoi = {};
export const itos = {};
for (let i = 0; i < chars.length; i++) {
const ch = chars[i];
stoi[ch] = i;
itos[i] = ch;
}
export function ceaser_cipher(string, n = 0){
string = string.replace(/[^a-zA-Z]/g, '').toLowerCase();
let result = "";
for (let i = 0; i < string.length; i++) {
let c = string[i];
result += itos[(stoi[c] + n) % 26]
}
return result;
}

Binary file removed pages/.crypto.js.swp
Binary file not shown.

0 comments on commit cab17d1

Please sign in to comment.