Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --After I looked this up on December 27th 2014, I found out this is basically (exactly) a hex Vigenere Ciphet
- local nify = { "0", "1","2","3","4","5","6","7","8","9","a","b","c","d","e","f" }
- local function code(key, msg, mode)
- key = tostring(key)
- msg = tostring(msg)
- local kn = 1
- local nmsg = ""
- for i = 1, #msg do
- cc = string.sub(msg, i, i)
- for b = 1, 16 do
- if cc == nify[b] then
- ccn = b
- end
- end
- for c = 1, 16 do
- if string.sub(key, kn, kn) == nify[c] then
- knn = c
- end
- end
- if mode == "encode" then
- ccn = ccn + knn
- elseif mode == "decode" then
- ccn = ccn - knn
- end
- if ccn >= 17 then
- ccn = ccn - 16
- end
- if ccn <= 0 then
- ccn = ccn + 16
- end
- --print(ccn)
- nmsg = nmsg..nify[ccn]
- if kn == #key then
- kn = 1
- else
- kn = kn +1
- end
- end
- return nmsg
- end
- function decode(key, msg)
- local tr = code(key, msg, "decode")
- return tr
- end
- function encode(key, msg)
- local tr = code(key, msg, "encode")
- return tr
- end
Advertisement
Add Comment
Please, Sign In to add comment