@name hatifnats encrypting(Web)
@inputs 
@outputs [Status Crypt]:string
@persist EnCanSay CanEnCrypt EnHttpDone EnDone
@persist DeCanSay CanDeCrypt DeHttpDone DeDone
@trigger 
runOnChat(1)
runOnHTTP(1)
runOnTick(1)

if(first()) {
    Data = "Nothing"
    #[print("")
    print("!encrypt <sentence> <password> to encrypt and")
    print("!decrypt <crypt> <password> to decrypt")
    print("NOTE: if you want to use space in the sentence or")
    print("password, please use underline _")
    ]#
}

LastSay = owner():lastSaid():explode(" ")

if(LastSay[1,string]:lower() == "!encrypt" & chatClk(owner())) {
    timer("ensay",800)
    CanEnCrypt = 1
}
if(CanEnCrypt & httpCanRequest()) {
    httpRequest("http://www.hatifnat.pcriot.com/crypt/?enword="+httpUrlEncode(LastSay[2,string])+"&enpassword="+httpUrlEncode(LastSay[3,string]))
}

if(clk("ensay")) {
    EnCanSay = 1
}
if(httpClk()) {
    EnHttpDone = 1
}
if(EnHttpDone&EnCanSay) {
    Crypt = httpData():sub(657,httpData():length()-66)
    EnHttpDone = 0
    EnCryptRequest = 0
    CanEnCrypt = 0
    EnDone = 1
}
if(EnDone&EnCanSay) {
    Done = 0
    EnCanSay = 0
    concmd("say encrypt: "+Crypt)
}


if(LastSay[1,string]:lower() == "!decrypt" & chatClk(owner())) {
    timer("desay",800)
    CanDeCrypt = 1
}
if(CanDeCrypt & httpCanRequest()) {
    httpRequest("http://www.hatifnat.pcriot.com/crypt/?deword="+httpUrlEncode(LastSay[2,string])+"&depassword="+httpUrlEncode(LastSay[3,string]))
}

if(clk("desay")) {
    DeCanSay = 1
}
if(httpClk()) {
    DeHttpDone = 1
}
if(DeHttpDone&DeCanSay) {
    Crypt = httpData():sub(657,httpData():length()-66)
    DeHttpDone = 0
    DeCryptRequest = 0
    CanDeCrypt = 0
    DeDone = 1
}
if(DeDone&DeCanSay) {
    DeDone = 0
    DeCanSay = 0
    concmd("say decrypt: "+Crypt)
}
