Encrypt.dll

From Moondust Wiki
Revision as of 20:11, 3 March 2015 by Hoeloe (talk | contribs)
Jump to navigation Jump to search

Download Latest Version

Encrypt is a closed library which allows encrypted saving of data.

Unlike the Data class, you can only save numbers to encrypted data files.

Requires bitwise.lua

Installation

Place the file encrypt.dll into the LuaScriptsLib folder.

How to use

To enable the Encrypt library for a specific level, add this line to lunadll.lua:

local encrypt = loadAPI("encrypt");

This will load the Encrypt API.

Example

local encrypt = loadAPI("encrypt");
    
--Defines a new encrypted data file
local edata = encrypt.Data(Data.DATA_LEVEL, "encryptedData", true);

function onLoad()
    edata:set("myVar", 1);
    edata:save();
end

function onLoop()
    printText(tostring(edata:get("myVar")),3,0,0);
end

This will save the value 1 to the variable myVar, as with the Data class, but will encrypt the data so it cannot be easily edited from the resulting text file.

Documentation

Classes

These are classes containing within this library

EData

Values

EData.data The underlying Data file used to read and write encrypted data. (NOT NECESSARY FOR USE).

Functions

EData:get key
Reads a value from the encrypted file. Returns nil if no value was found. number string

The variable name to read from the encrypted file.

EData:set key value
Writes a value to the encrypted file. number string

The variable name to write to the encrypted file.

number

The value to store in this key.

EData:save
Flushes data to the file on the disk. nil
EData.create data
Create a new encrypted file handler from an existing file handler. EData Data

The file handler to create an encrypted stream to.

External Use Functions

These are functions you will need to use the library

Data dataLevel fileName localSave
Creates an EData file handler for the specified file name, at the specified file access level. EData number

The data access level (e.g. Data.DATA_LEVEL) of the file.

string

The base name of the file.

boolean:optional

Should the data saved to this file be separate for each SMBX save file?