Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Vigen-re-cipher/AutoHotkey/vigen-re-cipher.ahk
Normal file
23
Task/Vigen-re-cipher/AutoHotkey/vigen-re-cipher.ahk
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Key = VIGENERECIPHER
|
||||
Text= Beware the Jabberwock, my son! The jaws that bite, the claws that catch!
|
||||
|
||||
out := "Input =" text "`nkey =" key "`nCiphertext =" (c := VigenereCipher(Text, Key)) "`nDecrypted =" VigenereDecipher(c, key)
|
||||
MsgBox % clipboard := out
|
||||
|
||||
VigenereCipher(Text, Key){
|
||||
StringUpper, Text, Text
|
||||
Text := RegExReplace(Text, "[^A-Z]")
|
||||
Loop Parse, Text
|
||||
{
|
||||
a := Asc(A_LoopField) - Asc("A")
|
||||
b := Asc(SubStr(Key, 1+Mod(A_Index-1, StrLen(Key)), 1)) - Asc("A")
|
||||
out .= Chr(Mod(a+b,26)+Asc("A"))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
VigenereDecipher(Text, key){
|
||||
Loop Parse, key
|
||||
decoderKey .= Chr(26-(Asc(A_LoopField)-65)+65)
|
||||
return VigenereCipher(Text, decoderKey)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue