Jump to content

Vigenère cipher: Difference between revisions

m
imported>Arakov
imported>Arakov
Line 1,179:
class VCipher
{
string encrypt(string txt, string pw, int d)
{
auto output := new TextBuilder();
int pwi := 0;
string PW := pw.toUpper();
var TXT := txt.toUpper().forEach::(t);
 
txt.toUpper().forEach::(t)
foreach(char t; in TXT) {
if(t >= $65){
if (t < {$65) $continue;
 
int tmp := t.toInt() - 65 + d * (PW[pwi].toInt() - 65);
int tmp := t - 65 + ifd * (tmppw[pwi] <- 065);
if (tmp < 0) tmp += {26;
output.write((65 + tmp += .mod(26)).toChar());
}pwi++;
if (pwi == PW.Length) { pwi := output.write((650 + tmp.mod(26)).toChar());}
pwi += 1};
 
if (pwi == PW.Length) { pwi := 0 }
^ }output.Value
};
^ output.Value
}
}
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.