Data update

This commit is contained in:
Ingy döt Net 2024-03-06 22:25:12 -08:00
parent ed705008a8
commit 0df55f9f24
2196 changed files with 32999 additions and 3075 deletions

View file

@ -6,30 +6,27 @@ import extensions;
class VCipher
{
string encrypt(string txt, string pw, int d)
{
auto output := new TextBuilder();
int pwi := 0;
string encrypt(string txt, string pw, int d)
{
auto output := new TextBuilder();
int pwi := 0;
string PW := pw.toUpper();
string PW := pw.toUpper();
var TXT := txt.toUpper();
txt.toUpper().forEach:(t)
{
if(t >= $65)
{
int tmp := t.toInt() - 65 + d * (PW[pwi].toInt() - 65);
if (tmp < 0)
{
tmp += 26
};
output.write((65 + tmp.mod:26).toChar());
pwi += 1;
if (pwi == PW.Length) { pwi := 0 }
}
};
foreach(char t; in TXT)
{
if (t < $65) $continue;
^ output.Value
}
int tmp := t - 65 + d * (pw[pwi] - 65);
if (tmp < 0) tmp += 26;
output.write((65 + tmp.mod(26)).toChar());
pwi++;
if (pwi == PW.Length) { pwi := 0 }
};
^ output.Value
}
}
public program()

View file

@ -1,4 +1,4 @@
import "/str" for Char, Str
import "./str" for Char, Str
var vigenere = Fn.new { |text, key, encrypt|
var t = encrypt ? Str.upper(text) : text