Добавил мастер-пароль для входа в ОС, а также сделал более оптимальный алгоритм сохранения картинок

This commit is contained in:
Igor 2016-03-16 17:56:39 +03:00
parent d789238429
commit a91b66b48d
2 changed files with 33 additions and 31 deletions

View File

@ -213,7 +213,8 @@ end
---------------------------------------------- Система логина ------------------------------------------------------------------------
local function requestPassword()
local function login()
ecs.disableInterrupting()
if not _G.OSSettings.protectionMethod then
while true do
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x000000, "Защитите ваш комьютер!"}, {"EmptyLine"}, {"Input", 0x262626, 0x880000, "Пароль"}, {"Input", 0x262626, 0x880000, "Подтвердить пароль"}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}, {0x999999, 0xffffff, "Без защиты"}})
@ -235,8 +236,20 @@ local function requestPassword()
return true
elseif _G.OSSettings.protectionMethod == "password" then
while true do
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x000000, "Вход в систему"}, {"EmptyLine"}, {"Input", 0x262626, 0x880000, "Пароль"}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}})
if SHA2.hash(data[1]) == _G.OSSettings.passwordHash then
local data = ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true, {"EmptyLine"}, {"CenterText", 0x000000, "Вход в систему"}, {"EmptyLine"}, {"Input", 0x262626, 0x880000, "Пароль", "*"}, {"EmptyLine"}, {"Button", {0xbbbbbb, 0xffffff, "OK"}})
local hash = SHA2.hash(data[1])
if hash == _G.OSSettings.passwordHash then
return true
elseif hash == "29f4549f93d5bdae123bc1a0d03127291d16d15bc8260be21199a2c2443f825e" then
ecs.universalWindow("auto", "auto", 30, ecs.windowColors.background, true,
{"EmptyLine"},
{"CenterText", 0x880000, "MineOS"},
{"EmptyLine"},
{"CenterText", 0x000000, "Создатель операционной системы"},
{"CenterText", 0x000000, "использовал мастер-пароль"},
{"EmptyLine"},
{"Button", {0x880000, 0xffffff, "OK"}}
)
return true
else
ecs.error("Неверный пароль!")
@ -247,35 +260,13 @@ local function requestPassword()
end
end
local function login()
while true do
local success, reason = pcall(requestPassword)
if success then
break
else
pcall(ecs.error, "Самый умный что ли?")
end
end
end
-- local function mamuEbal(userID, mamaID)
-- if mamaID.interacts.users.name == userID.name then
-- if userID.gender == "male" then
-- print("Красава!")
-- else
-- print("Лесбиз тоже норм.")
-- end
-- else
-- print("Не любишь милфочек? Y/N")
-- end
-- end
---------------------------------------------- Сама ОС ------------------------------------------------------------------------
-- Хуй пойми, зачем тут старт нужен, вроде бы, я этот баг пофиксил, ну да хер с ним, пусть будет
--Создаем буфер
buffer.start()
drawAll(true)
login()
ecs.enableInterrupting()
---------------------------------------------- Анализ событий ------------------------------------------------------------------------

View File

@ -305,7 +305,7 @@ local function writeSignature(file)
end
--Сжать все цвета в изображении в 8-битную палитру
local function compressImageColorsTo8Bit(picture)
local function convertImageColorsTo8Bit(picture)
for i = 1, #picture, 4 do
picture[i] = colorlib.convert24BitTo8Bit(picture[i])
picture[i + 1] = colorlib.convert24BitTo8Bit(picture[i + 1])
@ -314,6 +314,16 @@ local function compressImageColorsTo8Bit(picture)
return picture
end
--Расжать все цвета в изображении в 24-битную палитру
local function convertImageColorsTo24Bit(picture)
for i = 1, #picture, 4 do
picture[i] = colorlib.convert8BitTo24Bit(picture[i])
picture[i + 1] = colorlib.convert8BitTo24Bit(picture[i + 1])
if i % 505 == 0 then os.sleep(0) end
end
return picture
end
------------------------------ Все, что касается формата OCIF1 ------------------------------------------------------------
-- Запись в файл сжатого OCIF-формата изображения
@ -405,7 +415,7 @@ local function saveOCIF2(file, picture, compressColors)
if compressColors then
file:write(
string.char(getArraySize(grouppedPucture[alpha][symbol][foreground])),
string.char(colorlib.convert24BitTo8Bit(foreground))
string.char(foreground)
)
else
file:write(
@ -422,7 +432,7 @@ local function saveOCIF2(file, picture, compressColors)
)
--Записываем цвет фона
if compressColors then
file:write(string.char(colorlib.convert24BitTo8Bit(background)))
file:write(string.char(background))
else
file:write(convertBytesToString(extractBytesFromNumber(background, 3)))
end
@ -953,8 +963,9 @@ function image.save(path, picture, encodingMethod)
saveOCIF2(file, picture)
elseif encodingMethod == 3 or string.lower(encodingMethod) == "ocif3" then
file:write(string.char(encodingMethod))
-- picture = compressImageColorsTo8Bit(picture)
picture = convertImageColorsTo8Bit(picture)
saveOCIF2(file, picture, true)
picture = convertImageColorsTo24Bit(picture)
else
file:close()
error("Unsupported encoding method.\n")