Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[help plz D:] my encryption/decryption plugin's decryption is not working?

Asked by 4 years ago
Edited 4 years ago

hello, fellow scripters! so I am making a decrypter to decrypt my encryption, and this part is not working. for example, the decryption may be 23059140-23025582-23006406. (that is pie encrypted) and I need to put each lot of numbers in a table, so I made this:

function decrypt(code, PIN)
    local decryption = {}
    local ryt = 0
    print("decrypting")
    local lengnthy = string.len(code)
local len = string.len(code)
    for i = 1, len do
    wait(0.000000000001)
    print("yeet")

    local tg = {}
    for y = ryt, len do
        print(ryt)
        print("yeeeeee")
        wait(0.0000001)
        local letter = string.sub(code, y,y)
        print(letter)
        if letter == "-" then
            break
        else
            table.insert(tg, letter)
        end
    end
    print("decrypting letter")
    local full = table.concat(tg, "")
    print(full)
    local yeet = full / PIN
    yeet = full - PIN
--there is more down here, buti did not put it in.

the problem is, the first letter it prints is "-" when it is SUPPOSED to be 2. (line 17). can somebody help me?

1
What are you using this for? Vortex_Vasne 89 — 4y
0
the encryption software? i am just making it to test my skills, nothing important. codingMASTER398 52 — 4y

1 answer

Log in to vote
0
Answered by
cfiredog 274 Moderation Voter
4 years ago
Edited 4 years ago

You are overcomplicating things. I recommend that you use string.gsub or string.gmatch instead.

string.gsub

string.gsub(s, pattern, repl) returns a copy of s in which all (or the first n, if given) occurrences of the pattern have been replaced by a replacement string specified by repl, which can be a string, a table, or a function. gsub also returns, as its second value, the total number of matches that occurred.

In your case, simply replace all hyphens "-" with an empty string "":

local full = string.gsub(code, "-", "")

string.gmatch

string.gmatch(s, pattern) returns an iterator function that, each time it is called, returns the next captures from pattern over the string s. This is great for storing each character at a unique table index.

In your case, simply match all characters except for hyphens:

local tg = {}
local i = 1
for c in str:gmatch("[^-]") do
    tg[i] = c
    i = i + 1
end
0
the thing is, i want all of them in a seprate variable codingMASTER398 52 — 4y
0
I've edited my original post. Take a look. cfiredog 274 — 4y
Ad

Answer this question