Posted 09 March 2014 - 02:02 PM
Hello.
I've been thinking of making my own custom cryptography algorythm ( like my own hashing/encryption program/api )
But i am quite lost, of how i can make the output the same length no matter what length the input is.
my code:
I hope you can help me improve this method / if possible, ofc. / give suggestions on what to make the length the same etc.
And does anybody know, how i can turn it to be a hashing algorythm instead of pure encryptiong, so you cannot backtrace this process?
Thanks in Advance :D/>
I've been thinking of making my own custom cryptography algorythm ( like my own hashing/encryption program/api )
But i am quite lost, of how i can make the output the same length no matter what length the input is.
my code:
Spoiler
local MOD = 2^16
local MODM = MOD / 16
local MODMM = MODM / 128
local rotate = 2
local rrotate = 1
local function band(_X)
local inp={}
for char in string.gmatch(tostring(_X), ".") do
--print(char)
table.insert(inp, char)
end
local tbl=0
for time = 1, #inp do
for x = 1, rotate do
for i = 1, MOD/MODM do
tbl=math.floor((string.byte(inp[time])*MODMM+MODM*i)%i)+tbl+(string.byte(inp[time])%MODM) --[==[# this is the part where im quite lost... This is doing all the converting stuffz ( you can help me improve this xD--]==]
--[==[math.ceil((i*(string.byte(string.len(_X)[i])+i*x)))*MOD-rotate*MODM]==]
--print(#tbl)
--print(i.." Of "..MOD)
end
end
end
for i = 1, rrotate do
tbl=tbl..tbl
end
local tbl="--[ENC]^[==[->"..tostring(tbl).."<-]==]^[ENC]"
return tbl
end
I hope you can help me improve this method / if possible, ofc. / give suggestions on what to make the length the same etc.
And does anybody know, how i can turn it to be a hashing algorythm instead of pure encryptiong, so you cannot backtrace this process?
Thanks in Advance :D/>