Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function encryptNumber(number)
- number = (number < 65536 and number >= 0 and number) or false;
- if(not number)then return false; end
- local whole = math.floor(number);
- local decimal = number - whole;
- local wholeBin = {};
- for i = 1,16 do
- decimal = decimal * 2;
- wholeBin[16+i] = decimal-decimal%1;
- decimal = decimal%1;
- end
- for i = 1,16 do
- wholeBin[17-i] = whole%2;
- whole = math.floor(whole/2);
- end
- return wholeBin;
- end
- function decryptNumber(twholeBin)
- local decimal,whole = 0,0;
- for i = 32,17,-1 do
- decimal = decimal + twholeBin[i]*2^(32-i);
- end
- for i = 16,1,-1 do
- whole = whole + twholeBin[i]*2^(16-i);
- end
- return whole+decimal/65536;
- end
- function binToString(twholeBin)
- return table.concat(twholeBin,nil,1,16).."."..table.concat(twholeBin,nil,17):gsub("^0+",""):gsub("0+$","");
- end
Advertisement
Add Comment
Please, Sign In to add comment