Stock chart (since v 1.1.4.1) can accept encrypted data. This allows you to protect your data - people who will access your data file directly won't be able to see the real data. Stock chart allows you to use your own encryption algorithms - it will load additional swf file which you can create yourself and will use this file for decrypting data. To see how this works, open the encrypted_data example from examples folder.
1. First, you should encrypt your data. It is not recommended to use very complicated encryption methods, because it will slow down the data parsing. Here are some methods you can use:
You can use php, asp or any other language to encrypt your data. If you open data.csv from the encrypted_data folder you will see a lot of rows like this:
6*.#%P*,KKKK:**6:C,%P-KC-KKKP K~.C:C*,KKKK~~C~%C,K*-KC-KKKP *6.:6**,KKKKP~6~CP,C*-KC-KKKP :*.****,KKKK#*~PKP,CK-CC-KKKP
This is encrypted data which uses very simple algorithm - it flips data and then replaces numbers with some other symbols.
2. Create swf which would decrypt your data. Open decryptor.fla from the encrypted_data and check the actions of the first frame:
var replacement:Object = new Object();
replacement["K"] = 0;
replacement["C"] = 1;
replacement["P"] = 2;
replacement["*"] = 3;
replacement["~"] = 4;
replacement["$"] = 5;
replacement["6"] = 6;
replacement["%"] = 7;
replacement["#"] = 8;
replacement[":"] = 9;
// stock chart calls this function and should get the decrypted data back
// this file is loaded an function is only called only if you set <crf>[decryptor_file_name.swf]<crf> in the settings file
function deCrypt(data){
var arr = data.split("");
arr.reverse();
var count = arr.length;
for(var i = 0; i < count; i++){
for(var k:String in replacement){
if(arr[i] == k){
arr[i] = replacement[k];
}
}
}
var res = arr.join("");
return res;
}
The function deCrypt(data) receives encrypted data as an argument and then decrypts it doing backward the same actions which were made when encrypting the data. When finished, the function returns decrypted data. You should modify the script so that it would decrypt your data using the methods you used when encrypting. Before trying this on the chart, test it in the flash environment by tracing the results of the function:
trace(deCrypt(some_encrypted_data));
3. Tell the chart that the data is encrypted and it should use some file for decryption. All you need to do is to add the following line to your settings file:
<crf>decryptor.swf</crf>
Now the chart knows that the data is encrypted. You can use any name instead of "decryptor". The chart will look for this file in the "path" folder.
Note, this doesn't make your data 100% secure!