This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TNT_Nolan's profile picture

How to save a password in a file?

Started by TNT_Nolan, 13 April 2016 - 02:41 PM
TNT_Nolan #1
Posted 13 April 2016 - 04:41 PM
TNTAPI - http://www.computercraft.info/forums2/index.php?/topic/26474-tntapi-02-alpha/

Hello, I was wondering how to save a input inside of a file. This is my code so far.


os.loadAPI("tntapi")
tntapi.setScreen(1,4,colors.white,colors.black)
tntapi.easyText("Enter New Password",1,1,1)
password = io.read()

-- Save Password Here

Thanks,
Nolan
Lupus590 #2
Posted 13 April 2016 - 04:55 PM
have a look at the file system API: http://computercraft.info/wiki/Fs_%28API%29
moTechPlz #3
Posted 13 April 2016 - 05:15 PM
and more specifically fs.open http://computercraft.info/wiki/Fs.open

Open a file in write or append mode

local fileHandle = fs.open( "fileName", "w" )

then write to the file with the file handle you got. using 'write' or 'writeline'

fileHandle.writeLine( "Data" )

then close or flush to write the file

fileHandle.close( )
Edited on 13 April 2016 - 03:16 PM
Sewbacca #4
Posted 13 April 2016 - 06:07 PM
It will be more saftey to encrypt tbe password before saving.
Dragon53535 #5
Posted 13 April 2016 - 06:34 PM
It's be safer to hash the file than encrypt it. Take a look at this tutorial for FS though. Here.

Should help you with file systems.