Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
|
|
@ -1,13 +1,11 @@
|
|||
alpha$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
key$ = "VsciBjedgrzyHalvXZKtUPumGfIwJxqOCFRApnDhQWobLkESYMTN"
|
||||
#
|
||||
proc subst in$ . out$ a$ b$ .
|
||||
proc subst in$ &out$ &a$ &b$ .
|
||||
out$ = ""
|
||||
for c$ in strchars in$
|
||||
p = strpos a$ c$
|
||||
if p > 0
|
||||
c$ = substr b$ p 1
|
||||
.
|
||||
if p > 0 : c$ = substr b$ p 1
|
||||
out$ &= c$
|
||||
.
|
||||
.
|
||||
|
|
|
|||
30
Task/Substitution-cipher/JavaScript/substitution-cipher.js
Normal file
30
Task/Substitution-cipher/JavaScript/substitution-cipher.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
const key = "]kYV}(!7P$n5_0i R:?jOWtF/=-pe'AD&@r6%ZXs\"v*N[#wSl9zq2^+g;LoB`aGh{3.HIu4fbK)mU8|dMET><,Qc\\C1yxJ";
|
||||
|
||||
function encode(s) {
|
||||
let result = '';
|
||||
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
result += key[s.charCodeAt(i) - 32];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function decode(s) {
|
||||
let result = '';
|
||||
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
result += String.fromCharCode(key.indexOf(s[i]) + 32);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function main() {
|
||||
const s = "The quick brown fox jumps over the lazy dog, who barks VERY loudly!";
|
||||
const enc = encode(s);
|
||||
console.log("Encoded: ", enc);
|
||||
console.log("Decoded: ", decode(enc));
|
||||
}
|
||||
|
||||
main();
|
||||
Loading…
Add table
Add a link
Reference in a new issue