Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


IO: load, read, write and save from and to stream file

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater
Reputation: 26

Joined: 10 Apr 2015
Posts: 914

PostPosted: Fri Jul 22, 2016 3:45 am    Post subject: IO: load, read, write and save from and to stream file Reply with quote

I've tried to make a simple Login form use CE create form. It just contain user name and password as a user database (store in local file as a text file). Not use internet or MySqL as a database.

Now, i want use user database file store, load, read , write and save as stream file as part this CT file. I am use io:file statement.

Is it possible ?. And how put a lookup function to check new or exist user by check the user database file?

Code:

-----------------------------------------------------------------------
--- load user data file stored in stream
function loadTableCode(n2)
 local t2 = findTableFile(n2)
 if t2 ~= nil then
 local s2 = t2.Stream
 local c2 = readStringLocal(s2.Memory,s2.Size)
 return c2 ~= nil and loadstring(c2)
 end
end

local f2 = loadTableCode('userdata.txt')
print(type(f2))
if type(f2) == 'function' then f2() else print('not loaded') end   --- need put a function in txt file?
-----------------------------------------------------------------------

--- Check for new / exist user from user database
function getUserLogin()
local a = control_getCaption(UDF1.CEEdit1)
a = tostring(a)
if a == "" then
 showMessage("Please input user name and password")
 return
end
local b = control_getCaption(UDF1.CEedit2)
b = tostring(b)
if b == "" then
 showMessage("Please input your email and password")
 return
end
 local a = control_getCaption(UDF1.CEEdit1)
 a = tostring(a)
 fh =  io.open("userdata.txt")    --- io.open("E:\\userdata.txt")  use local drive
 while true do
 line = fh:read()
  if line == nil then break end
   -- print (line)
  if string.find(line,a) then
   showMessage("Login accepted !")
   fh:close()
   break
  else
   showMessage("You must register first!")
   control_setCaption(UDF1.CEEdit1,"")
   control_setCaption(UDF1.CEEdit2,"")
   a = ""
   b = ""
   fh:close()
   break
  end
 end
end

function userRegister()
local a = control_getCaption(UDF1.CEEdit1)
a = tostring(a)
if a == "" then
 showMessage("Please input your email and password")
 return
end
local b = control_getCaption(UDF1.CEedit2)
b = tostring(b)
if b == "" then
 showMessage("Please input your email and password")
 return
end
 local file =  io.open("userdata.txt")  --- io.open("E:\\test.txt")
 while true do
 line = file:read()
  if line == nil then break end
   -- print (line)
  if string.find(line,a) then
   showMessage("You already registered")
   control_setCaption(UDF1.CEEdit1,"")
   control_setCaption(UDF1.CEEdit2,"")
   a = ""
   b = ""
   file:close()
   break
  else
   local file =  io.open("userdata.txt")  ---io.open("E:\\test.txt", "a")
   file:write(a.."/"..b, "\n")
   showMessage("Registering Complete !")
   beep()
   control_setCaption(UDF1.CEEdit1,"")
   control_setCaption(UDF1.CEEdit2,"")
   file:close()
  break
 end
end
end
--


function CEButton1Click(sender)
getUserLogin()
end
--
function CEButton2Click(sender)
userRegister()
end
--
function CEButton3Click(sender)
closeCE();
return caFree
end


Thank and regards
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 122

Joined: 09 Jun 2013
Posts: 3279

PostPosted: Fri Jul 22, 2016 8:16 am    Post subject: Reply with quote

Not sure of the method to save a file back into the table, but you would use findTableFile(filename) to retrieve it.

There would also be a major flaw in this implementation approach.

When you release a new version of the table, it's going to wipe out their local copy of the file.

Side note, I wouldn't want my email and password sitting out there in some text file.
Back to top
View user's profile Send private message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Fri Jul 22, 2016 12:05 pm    Post subject: Reply with quote

I don't think anyone's gonna download something that stores and saves their information like that...
Back to top
View user's profile Send private message
predprey
Master Cheater
Reputation: 17

Joined: 08 Oct 2015
Posts: 417

PostPosted: Fri Jul 22, 2016 12:36 pm    Post subject: Reply with quote

Implement a hash, a salt, and an AES-256 encryption onto the password function Laughing
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater
Reputation: 26

Joined: 10 Apr 2015
Posts: 914

PostPosted: Fri Jul 22, 2016 7:21 pm    Post subject: Reply with quote

Thanks for you all.
Here are just about the possibility of applying the statements lua IO; to manage database files. Is it possible or not.

Of course we will not share or store our private data such as email and password, etc. with risky situation, anyhow I am trying here is to create a login system that requires the user to verify before being allowed to use the game trainer.

Thank for hint findTableFile(filename) from Zanzer and Implement a hash, a salt, and an AES-256 encryption as suggest by predprey.

So, the conclusion is better use online database such as MySQL to store user database with encryption. Maybe use LuasSocket or other method.

Rgds
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 28

Joined: 13 Sep 2011
Posts: 1456

PostPosted: Sat Jul 23, 2016 9:46 am    Post subject: Reply with quote

Lua socket is ideal, and yes you should use online database for this, never save information as a plain.
Implement as little as possible on the client more on the server.

I do not know if there luasocket plugin for C.E 6.5.1, but you could user the getInternet function,which allows you to get/post, though it's missing some functions that I found them useful.

hope DB could add the lua socket
Code:
ltn12.sink
class functions into C.E.
_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater
Reputation: 26

Joined: 10 Apr 2015
Posts: 914

PostPosted: Thu Jul 28, 2016 9:08 am    Post subject: Reply with quote

Thanks DaSpammer,

I still try implementing LuaSocket for my project.

Regards
Back to top
View user's profile Send private message
Lynxz Gaming
Expert Cheater
Reputation: 1

Joined: 01 Jul 2017
Posts: 164

PostPosted: Wed Dec 05, 2018 8:47 am    Post subject: Re: IO: load, read, write and save from and to stream file Reply with quote

Aylin maybe i can help you, my discord is Lynxz Gaming#9443
_________________
<3 Yuki Tanaka
Back to top
View user's profile Send private message
noobesgt
Cheater
Reputation: 0

Joined: 17 Dec 2018
Posts: 42

PostPosted: Fri Dec 28, 2018 1:20 pm    Post subject: Reply with quote

f1 = io.input ("C:\\Users\\"..UDF1.CEEDit5.text.."\\Desktop\\"..UDF1.CEEdit4.text)
repeat
s1 = f1:read ("*l") -- read one line
if s1 then -- if not end of file (EOF)
UDF1.CEEdit2.text = s1 -- print that line
end
until not s1 -- until end of file

f1:close () -- close that file now

end

_________________
I'm 1337
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites