mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
encrypt password and account number
* the encryption uses a unique machine key, this means that if anyone steals config.otml with a saved password, he will not be able to decrypt the password without the machine UUID key * the encrypt uses a simple XOR encryption method, encoded with base64 and adler32 summing
This commit is contained in:
@@ -40,7 +40,7 @@ local function tryLogin(charInfo, tries)
|
||||
|
||||
CharacterList.destroyLoadBox()
|
||||
|
||||
g_game.loginWorld(EnterGame.account, EnterGame.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
|
||||
g_game.loginWorld(G.account, G.password, charInfo.worldName, charInfo.worldHost, charInfo.worldPort, charInfo.characterName)
|
||||
|
||||
loadBox = displayCancelBox(tr('Please wait'), tr('Connecting to game server...'))
|
||||
connect(loadBox, { onCancel = function()
|
||||
@@ -81,6 +81,10 @@ function CharacterList.init()
|
||||
connect(g_game, { onConnectionError = onGameConnectionError })
|
||||
connect(g_game, { onGameStart = CharacterList.destroyLoadBox })
|
||||
connect(g_game, { onGameEnd = CharacterList.showAgain })
|
||||
|
||||
if G.characters then
|
||||
CharacterList.create(G.characters, G.premDays)
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterList.terminate()
|
||||
@@ -100,7 +104,9 @@ function CharacterList.terminate()
|
||||
end
|
||||
|
||||
function CharacterList.create(characters, premDays)
|
||||
CharacterList.show()
|
||||
G.characters = characters
|
||||
G.premDays = premDays
|
||||
|
||||
characterList:destroyChildren()
|
||||
local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
|
||||
|
||||
|
@@ -3,8 +3,6 @@ EnterGame = { }
|
||||
-- private variables
|
||||
local loadBox
|
||||
local enterGame
|
||||
local motdNumber
|
||||
local motdMessage
|
||||
local motdButton
|
||||
local enterGameButton
|
||||
|
||||
@@ -29,15 +27,15 @@ local function onError(protocol, message, connectionError)
|
||||
end
|
||||
|
||||
local function onMotd(protocol, motd)
|
||||
motdNumber = tonumber(motd:sub(0, motd:find("\n")))
|
||||
motdMessage = motd:sub(motd:find("\n") + 1, #motd)
|
||||
G.motdNumber = tonumber(motd:sub(0, motd:find("\n")))
|
||||
G.motdMessage = motd:sub(motd:find("\n") + 1, #motd)
|
||||
motdButton:show()
|
||||
end
|
||||
|
||||
local function onCharacterList(protocol, characters, premDays)
|
||||
if enterGame:getChildById('rememberPasswordBox'):isChecked() then
|
||||
Settings.set('account', EnterGame.account)
|
||||
Settings.set('password', EnterGame.password)
|
||||
Settings.set('account', g_crypt.encrypt(G.account))
|
||||
Settings.set('password', g_crypt.encrypt(G.password))
|
||||
Settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
|
||||
else
|
||||
clearAccountFields()
|
||||
@@ -47,11 +45,12 @@ local function onCharacterList(protocol, characters, premDays)
|
||||
loadBox = nil
|
||||
|
||||
CharacterList.create(characters, premDays)
|
||||
CharacterList.show()
|
||||
|
||||
local lastMotdNumber = Settings.getNumber("motd")
|
||||
if motdNumber and motdNumber ~= lastMotdNumber then
|
||||
if G.motdNumber and G.motdNumber ~= lastMotdNumber then
|
||||
Settings.set("motd", motdNumber)
|
||||
local motdBox = displayInfoBox(tr('Message of the day'), motdMessage)
|
||||
local motdBox = displayInfoBox(tr('Message of the day'), G.motdMessage)
|
||||
connect(motdBox, { onOk = CharacterList.show })
|
||||
CharacterList.hide()
|
||||
end
|
||||
@@ -65,8 +64,12 @@ function EnterGame.init()
|
||||
motdButton:hide()
|
||||
Keyboard.bindKeyDown('Ctrl+G', EnterGame.openWindow)
|
||||
|
||||
local account = Settings.get('account')
|
||||
local password = Settings.get('password')
|
||||
if G.motdNumber then
|
||||
motdButton:show()
|
||||
end
|
||||
|
||||
local account = g_crypt.decrypt(Settings.get('account'))
|
||||
local password = g_crypt.decrypt(Settings.get('password'))
|
||||
local host = Settings.get('host')
|
||||
local port = Settings.get('port')
|
||||
local autologin = Settings.getBoolean('autologin')
|
||||
@@ -119,14 +122,14 @@ function EnterGame.openWindow()
|
||||
end
|
||||
|
||||
function EnterGame.doLogin()
|
||||
EnterGame.account = enterGame:getChildById('accountNameTextEdit'):getText()
|
||||
EnterGame.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||
EnterGame.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
||||
EnterGame.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
||||
G.account = enterGame:getChildById('accountNameTextEdit'):getText()
|
||||
G.password = enterGame:getChildById('accountPasswordTextEdit'):getText()
|
||||
G.host = enterGame:getChildById('serverHostTextEdit'):getText()
|
||||
G.port = tonumber(enterGame:getChildById('serverPortTextEdit'):getText())
|
||||
EnterGame.hide()
|
||||
|
||||
Settings.set('host', EnterGame.host)
|
||||
Settings.set('port', EnterGame.port)
|
||||
Settings.set('host', G.host)
|
||||
Settings.set('port', G.port)
|
||||
|
||||
local protocolLogin = ProtocolLogin.create()
|
||||
protocolLogin.onError = onError
|
||||
@@ -140,9 +143,9 @@ function EnterGame.doLogin()
|
||||
EnterGame.show()
|
||||
end })
|
||||
|
||||
protocolLogin:login(EnterGame.host, EnterGame.port, EnterGame.account, EnterGame.password)
|
||||
protocolLogin:login(G.host, G.port, G.account, G.password)
|
||||
end
|
||||
|
||||
function EnterGame.displayMotd()
|
||||
displayInfoBox(tr('Message of the day'), motdMessage)
|
||||
displayInfoBox(tr('Message of the day'), G.motdMessage)
|
||||
end
|
||||
|
Reference in New Issue
Block a user