Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autokey Encryption is not there in this. #32

Open
GameEntity903 opened this issue Dec 27, 2022 · 2 comments
Open

Autokey Encryption is not there in this. #32

GameEntity903 opened this issue Dec 27, 2022 · 2 comments

Comments

@GameEntity903
Copy link

I'm currently working on one method to do it. I noticed that all other major cryptography functions were there but not this. That's all I have to say. P.S. Decoding is much harder than encoding.

@Chunjee
Copy link

Chunjee commented Dec 27, 2022

https://en.wikipedia.org/wiki/Autokey_cipher

An autokey cipher (also known as the autoclave cipher) is a cipher that incorporates the message (the plaintext) into the key. The key is generated from the message in some automated fashion, sometimes by selecting certain letters from the text or, more commonly, by adding a short primer key to the front of the message.

There are two forms of autokey cipher: key-autokey and text-autokey ciphers. A key-autokey cipher uses previous members of the keystream to determine the next element in the keystream. A text-autokey uses the previous message text to determine the next element in the keystream.

@GameEntity903
Copy link
Author

Encoding and Decoding functions. No idea whether this is fully optimized or not.

AutoKeyEnc(Primer,Input) ;GameNtt
{
alphacount := 0
spacecount := 0
spacecount2 := 0
Loop, Parse, Input
{
chint := Asc(A_LoopField)
if(((chint >= 65) && (chint <= 90)) || ((chint >= 97) && (chint <= 122)))
alphacount++
else if(chint == 32)
{
spacecount++
if(A_Index > (StrLen(Input)-StrLen(Primer)))
spacecount2++
}
}
alphacount := alphacount - StrLen(Primer)
totalcount := alphacount + spacecount - spacecount2
Return Vigenere((Primer . SubStr(Input, 1, totalcount)),Input)
}

AutoKeyDec(Primer,Input) ;GameNtt
{
Inlen := StrLen(Input)
PrimerLen := StrLen(Primer)
Primer2 := Primer
Primer2Len := StrLen(Primer2)
nofloops := (Inlen//PrimerLen)+1
Loop, %nofloops%
{
output := VigenereDec(Primer2,(SubStr(Input,1,Primer2Len)))
Primer2 := Primer . output
Primer2Len := StrLen(Primer2)
}
Return output
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants