The best way to save game data in Unity that's secure & platfrom independent - unity3d

I am looking for a way to save the users progress for my game, I am looking for something that can't be tampered with/modified. I would like to have to be able to be platform independent. And I would like it to be stored within the game files to the user can transfer their data to different computers (with a flash drive or something). (Correct me if I'm wrong in any area) But I believe because I need to to be secure and platform independent that removes player prefs from the equation. I know there is a way to save data by encrypting it with Binary, but I don't know how that works and if the user could transfer the data from computer to computer. Is there a better way of saving data? Is encrypting is through Binary the way to go? If so how would I do it? Thank you :) If you have any questions feel free to ask.
Edit: I understand nothing is completely secure, I'm looking for something that can stop the average user from going into a file, changing a float, and having tons and tons of money in game.

The previous answer mentiones two good methods for storing data (although there are still some quirks regarding writing files on different platforms), I'd like to add on to the subject of security, as mentioned in a comment here.
First of all, nothing is fully secure, there is always someone brighter out there that will find a flaw somewhere in your code, maybe unless you want full on crypto, which is not trivial with key management etc.
I understand from the question that he wants to prevent users from moving files between machines, or allow them to move the files between machines but seal them so that users cannot easily change data stored in them.
In either case, a trivial solution would work: generate a hashcode from your dataset, mangle with it a little bit (salt it or do whatever to jump to another hashcode). so you could have something like
{
"name"="john",
"score"="1234",
"protection"="043DA33C"
}
if the 'protection' field is a hashcode of "john1234", it will not match "john9999", hence if the user doesn't know how you salt your protection, you will be able to tell that the save has been tampered with

The first way to save data in unity is use PlayerPrefs, using for example:
PlayerPrefs.SetString("key","value");
PlayerPrefs.SetFloat("key",0.0f);
PlayerPrefs.SetInt("key",0);
PlayerPrefs.Save();
and for get, you only need
PlayerPrefs.GetString("key","default");
The second way and the way that permit you stored in a independent file is use serialization, my prefer way is a use the json file for it.
1) make a class that will store the data (not necessarily it need extends of monobehaviour:
[System.Serializable]
public class DataStorer {
public data1:String = "default value";
public data2:Int = 4;
public data3:bool = true;
....
}
and store it in another class with
DataStorer dataStorer = new DataStorer();
.... // some change in his data
string json = JsonUtility.ToJson(this, true);//true for you can read the file
path = Path.Combine(Application.persistantDataPath, "saved files", "data.json");
File.WriteAllText(path, json);
and for read the data
string json= File.ReadAllText(path);
DataStorer dataStorer = new DataStorer();
JsonUtility.FromJsonOverwrite(json, dataStorer);
and now you dateStorer is loaded with the data in your json file.

I found a link of data encryption tool, which is very helpful according to your need, as you want to secure data on device (nothing 100% secure), there are 3 mode to secure data, APP, Device and Encryption key, you can choose as per your need.
See this link, it may help you.
https://forum.unity.com/threads/data-encryption-tool-on-assets-store.738299/

Related

How can I decrypt the Triplestore files of an RDF4J database?

I am currently trying to read the files of an RDF4J triplestore from the universAAL platform and put them into an InfluxDB to merge the data from different smart living systems.
However, I have noticed that the individual index files of the Native repository are encrypted/unreadable (See image below).
Is there any experience from the community on how to get human readable content out of the RDF4J files (namespace, triples.prop, triples-cosp, triples-posc, triples-spoc, values.hash, values.dat, values.id) and merge them into another database?
The documentation of RDF4J did not help me here, so I could not create a decent export.
Encrypted File from Triplestore
The files are not encrypted, they're simply a binary format, optimized for efficient storage and retrieval, used by RDF4J's Native Store database implementation. They're not meant for direct manipulation.
The easiest way to convert them to readable RDF is to spin up a Native Store on top of them and then use the RDF4J API to query/export its data. Assuming you have a complete set of data files it should be as simple as something like this:
Repository rep = new SailRepository(new NativeStore(new File("/path/to/datafiles/");
try(RepositoryConnection conn = rep.getConnection()) {
conn.export(Rio.createWriter(RDFFormat.TURTLE, System.out));
}
finally {
rep.shutDown();
}
Obviously, replace System.out with a FileOutputstream if you want to write the data to file rather than the console. And change RDFFormat.TURTLE to something else if you want a different syntax format.

Process SAZ files using FiddlerScript or extension

I've a series of Fiddler session archive files (SAZ), ~150 with huge number of sessions per file, ~15k entries. Per documentation I can use the AutoResponder feature to mimic the sessions for replay. However, I'm finding it awkward to import the sessions from SAZ files into AutoResponder as the list gets pretty large and the manual entries in AutoResponder rules becomes hard to locate.
I was wondering is there a way to read and locate the session from SAZ file directly using FiddlerScript or extension without going into AutoResponder tab. I'm not familiar with JS.NET or C#, but I'm trying to write some crude logic.
The closest I saw was I have problems to readSessionArchive() in FiddlerScript. Using the shared snippet, I could make it working just to list the sessions from SAZ. Is there a way to map the response from the SAZ file to the request in context just like when it's imported in AutoResponder?
Modified version from the above link:
for (var i1:int = 0; i1<sSessions.Length; ++i1)
{
FiddlerObject.log("sSessions: " + i1 + ": " + sSessions[i1].url);
if(sSessions[i1].url === 'example.com/default.css') {
//FiddlerObject.log("sSessions: " + i1 + ": " + sSessions[i1].GetResponseBodyAsString());
//TODO logic to map oSession.response = response stored in SAZ file
}
}
Is there any better way to achieve this? Also, I feel every time it's parses through all session entries in SAZ, there's lot of I/O activity. Is there any alternate without going for DB option?
Are you trying to implement your own AutoResponder using the extensibility model? If so, is the idea that you don't want to lose track of manual entries in the UI because there are so many imported entries? It seems like you could just keep your manual entries at the top?
If you like, you can selectively add Sessions (after you've loaded and/or modified them) to the AutoResponder UI using oAutoResponder.ImportSessions.
How big is the SAZ file?
Fiddler will only hit the disk when you call Utilities.ReadSessionArchive; after that, the Sessions are all in Fiddler's memory. If you're seeing disk IO here, it suggests that your machine is low on memory and your OS is paging memory to and from disk.
Is there a way to map the response from the SAZ file to the request in context
I'm not fully sure I understand what you're asking-- are you asking how Fiddler decides what a Session's URL is? Because it looks like you've already figured that out in your code snippet.

Sending MMS on iPhone using CoreTelephony

I am interested in sending an MMS within a private application on the iPhone. A lot of the information I need is proprietary, and therefore I can't find it anywhere. Basically, I'm looking for the proper way to construct a CTMessage and encode it for MMS, and then sending it via one of the overloaded sendMMS functions. Thanks in advance.
For those interested: here is what I managed to dig up (&/OR piece together myself).
For every MMS, a CTMessage is allocated & initialized. addRecipient/setRecipient is called to do just that.
For each data/text section a CTMessagePart is built with its data and corresponding datatype, and then added to the CTMessage's items array. The first item in each MMS items array is always a CTMessagePart containing a SMIL-formatted layout that the recipient interprets to display the message. Each CTMessagePart following the first is in the order that it is referenced from the SMIL data.
Each (unmodifiied) iPhone has an instance of CTMessageCenter running, with the id sharedMessageCenter. Calling sharedMessageCenter's sendMMS, giving the id of the CTMessage you just created will automate the rest of the process. Essentially, the CTMessage is encoded using the CTMmsEncoder into an MMS-PDU hex string. (Not to sure of the correct name for it, hah). Anyways, sharedMessageCenter's send method will then send the (encoded) MMS to your provider's MMSC.
That pretty much sums it up, and should give anyone looking to head down that path a good place to start depending on what they're doing. I can do my best to answer any questions.

saving segmented images from a number plate

hye everyone i m doing my project "automatic vechicle identification".i have to design software in matlab,i have done extraction of plate region ,segmentation of characters,...now i want to save these segmented characters so that i can further recognize these character from a data base......any body can help me please feel free to write to me, thanks in advance
So if you have some data, myData then you can just issue a command save myData and you will have a new file in the current directory named myData.mat. To load the data later, just type in load myData and then you will have a new variable in the workspace named myData. There's lots more you can do with this, so you should check out help save.
Alternatively you could use a database. I've never actually used a database in Matlab, but there seems to be plenty of information about how one would go about doing this: http://www.mathworks.com/help/toolbox/database/ug/database.html

How do I use IPTC/EXIF metadata to categorise photos?

Many photo viewing and editing applications allow you to examine and change EXIF and IPTC data in JPEG and other image files. For example, I can see things like shutter speed, aperture and orientation in the picture files that come off my Canon A430. There are many, many name/value pairs in all this metadata. But...
What do I do if I want to store some data that doesn't have a build-in field name. Let's say I'm photographing an athletics competition and I want to tag every photo with the competitor's bib number. Can I create a "bib_number" field and assign it a values of "0001", "5478", "8124" etc, and then search for all photos with bib_number="5478"?
I've spent a few hours searching and the best I can come up with is to put this custom information in the "keywords" field but this isn't quite what I'm after. With this socution I'd have to craft a query like "keywords contains bib_number_5478" whereas what I want it "bib_number is 5478".
So do the EXIF and/or IPTC standards allow addtional user-defined field names?
Thanks
Kev
It can be used for that, but it really shouldn't: it's meant to be user-editable and so isn't a safe place to put critical metadata. Using an XMP sidecar is better for this kind of thing: in XMP, any field added that a given app does not understand is, according to the standard, supposed to be ignored by that app and not destroyed.
I don't know if there are applications to do this but by the standards described for JPEG files there is a field called Comments where you can assign values that could act like tags.
C# code:
using System.Windows.Media.Imaging;
using System.IO;
...
FileStream fs = new FileStream(#"<img_path>", FileMode.Open, FileAccess.ReadWrite);
BitmapMetadata bmd = (BitmapMetadata)BitmapFrame.Create(fs).Metadata;
bmd.Comment = "Some Comment Here";
also if you are looking for an application that already has this functionality built into it, then might i recommend Irfan View (open pic, go to Image menu, click on Comments button).
Hope this helps.