How to encrypt a string using InstallScript - encryption

I'm building an installer using InstallScript MSI project. During installation I save some information to a local file. This file is created based on the user's preferences and it may contain sensitive information.
I would like to encrypt this information but couldn't find any InstallScript function to handle this. I know I can have feature files encrypted, but this file is create during installation and is not a part of a specific feature.
Does anyone know of a way to encrypt strings using InstallScript?
Thanks!

Like KMoraz wrote - I don't know of a builtin function for this.
For what it's worth - the way I do it is by using an external COM DLL to do the encryption/decryption for me.
You will of course need to obtain/create such a DLL to use and deploy it with the installation.
(I use pure installscript installation - not MSI)
function STRING Encryption(bEncrypt,sInput)
STRING sEncryptionKey, sResult;
OBJECT oEncryption;
begin
try
// create encryption key
sEncryptionKey = "key";
// create COM object
set oEncryption = CoCreateObject("Encryption");
if (IsObject(oEncryption)) then
// set encryption key
oEncryption.Initialize(sEncryptionKey);
if (bEncrypt = TRUE) then
sResult = oEncryption.Encode(sInput);
else
sResult = oEncryption.Decode(sInput);
endif;
endif;
// free object
set oEncryption = NOTHING;
catch
sResult = "";
endcatch;
return sResult;
end;
Hope this helps in any way.

Related

how can I change in memory db to file db In JAVA?

The sqlite configuration in spring boot is
sqlite.datasource.url=jdbc:sqlite::memory:
I confirmed that the data was inserted, but I want to get this sqlite as a real file.
Do you know what to do?
.properties setting
spring.datasource.url=jdbc:sqlite:file:memorydb.db?mode=memory&cache=shared
test code
Connection conn = DriverManager.getConnection("jdbc:sqlite:file:memorydb.db?mode=memory&cache=shared");
Statement stmt = conn.createStatement();
File tmpFile = File.createTempFile(name, ".db");
stmt.executeUpdate("backup to " + tmpFile.getAbsolutePath());
tmpFile.deleteOnExit();
stmt.close();
Not sure why you'd want to do that because normally one would say that they want to move from using an in-memory database to an actual persistence database. So if I'm getting you correctly, you want to know how to write data to a file please refer to this article https://www.journaldev.com/878/java-write-to-file. So being able to write to a file is not an alternative but a database and doing this can co-exist.
Hope this helps ;)

Import an External SQLite database to my project

I'm interested in importing an external SQLite database to my project.
When using the QT Quick Local Storage:
LocalStorage.openDatabaseSync("QQmlExampleDB", "1.0", "The Example QML SQL!", 1000000);
The problem is that, the program generates a NEW database, and if it's possible I'm interested in open an existing database.
Any idea?
Thank you very much!
Thanks all of you, with the information you have got me I could solve my problem, all the things I have had to do are:
First of all in main.cpp I set my offline Storage Path:
engine.setOfflineStoragePath(QString("./"));
Then I also add this code:
QDir dir("./Databases");
if (!dir.exists()) {
dir.mkpath(".");
}
QString new_name = QString(QCryptographicHash::hash(("nameofthecopiedDB"),QCryptographicHash::Md5).toHex());
QFile file(":/SQLite/nameofsourceDB.sqlite");
file.copy("./Databases/" + new_name + ".sqlite");
file.close();
Since I have the DB I would to use in my project in SQLite folder from my resources (:, indicates resources).
And then, in QML file, the openDatabaseSync() function:
basedades = Sql.LocalStorage.openDatabaseSync('nameofthecopiedDB',"1.0","Els meus entrenaments",1000000,"QSQLITE")
Thank you!
openDatabaseSync searches or creates dbs in the directory used for storing offline data.
That directory is identified by the data member offlineStoragePath of the QQmlEngine class.
To change it, you can use the the member method setOfflineStoragePath (see here for further details).
The first argument for openDatabaseSync is:
The name of the database passed to openDatabase()
See here for further details.

Can the Path assigned a SQLite DB be an arbitrary value?

In this blog post, some prerequisite code for getting started using SQLite in Windows Store Apps is given, for adding to the OnLaunched method of App.xaml.cs:
// Get a reference to the SQLite database
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "customers.sqlite");
My question is: Can I use any arbitrary value to replace the "customers.sqlite" part, or does it have to match something else in my code, such as the name of my table definition class (in my case "PhotraxCoreData.cs" which, according to Mr. Green's suggestion, I added below a newly-created "Models" folder)?
My understanding is that, once I've got those classes defined (I do), and the code above in App.xaml.cs, along with this there (adapted for my SQLite classes):
using (var db = new SQLite.SQLiteConnection(this.DBPath))
{
// Create the tables if they don't exist
db.CreateTable<PhotraxBaseData>();
db.CreateTable<PhotraxNames>();
db.CreateTable<PhotraxQueries>();
}
...SQLite tables based on those classes I specified will be created, and have the name "customers.sqlite" (provided I don't change it).
So, can I use:
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "platypus.sqlite");
...or must it be something like:
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "PhotraxCoreData.sqlite");
That database name is just a file name.
The directory must be accessible by your app, but the file name can be anything.
AS CL says, the file name can be anything the app has direct access to. Windows Store apps have limited access to the file system, so the sqlite database must be in either the apps install location (read only) or it's app data folder (read write). A common pattern is to ship a seed database in the app package and then copy it from the install location to app data on first use so it can be written to.

ASP.NET creating resources at runtime

I'm developing an ASP.NET webapp that has a multilanguage feature allowing the webmaster to create new languages at runtime.
The approach that I was thinking is the following:
The user selects one available (not created) language.
When the user confirms, the application automatically copies a set of existing resources, replacing the filename with the new culture. For example: default.aspx.en-us.resx to default.aspx.es-ar.resx.
The user edits the recently created resources.
Currently I'm having troubles with step number 2. I've achieved to copy the resources, but then these new resources are ignored. I think that this happens because the new resources are not included in the running assembly, and therefore are being ignored.
When I test the following code in my local project, I would have to manually add the new resources to the solution and then recompile to make it work.
Does anyone know how to make this work?
This is the code of the mentioned copy.
string _dir = path_ + "App_LocalResources\\\\";
DirectoryInfo _dirInfo = new DirectoryInfo(_dir);
foreach (FileInfo _file in _dirInfo.GetFiles("*en-us.resx")) {
_file.CopyTo(_dir + _file.Name.Replace("en-us", idioma_.Cultura));
}
string _dir2 = path_ + "App_GlobalResources\\\\";
_dirInfo = new DirectoryInfo(_dir2);
foreach (FileInfo _file in _dirInfo.GetFiles("*en-us.resx")) {
_file.CopyTo(_dir2 + _file.Name.Replace("en-us", idioma_.Cultura));
}
Thank you very much.
Creating or editing Resource files is not possible the same way as reading data.
In order to create or edit a resource file, you should do it the same way you create or edit XML files because resource files have with a specific structured XML elements.
Maybe this article will help you...

Saving a file in Flex Air

I'm trying to copy my SQLite file that is used in my Air app to user's selected directory using
var fileSaveDest:FileReference = new FileReference();
fileSaveDest.save(dbWorkedFile,'Inventory.DB');
dbWorkedFile is a File
dbWorkedFile = File.documentsDirectory.resolvePath("Inventory.db");
I tried this but the saved file isn't a valid SQLite file.
Also, I was wondering whether it's possible to embed SQLite to Air? If so how can I import and export the database?
Many thanks
In the end I couldn't get FileReference.save() to work so I go with the regular File's browseForSave()
dbWorkedFile.addEventListener(Event.SELECT, savingDatabase);
dbWorkedFile.browseForSave('Specify save location');
private function savingDatabase(event:Event):void
{
var selectedFile:File = File(event.target);
//To ensure the file is still loaded
dbWorkedFile = File.applicationStorageDirectory.resolvePath("Inventory.db");
dbWorkedFile.copyTo(selectedFile, true);
}
There is a short article describing how to include some SQLLite files in an AIR application on Adobe website (cookbooks section).

Resources