Closed vhugogarcia closed 7 years ago
I forked this project and fixed 3 of the issues. I will release it to nuget.
Thanks @alexrainman Could you share the link of the new fork you released in nuget, please?
Is that fork compatible with PCLCrypto 2.0?
Hello @alexrainman I found the nuget package, however when I installed it I keep getting this error:
/Users/Demo/Services/LocalDatabase/Content/DemoManager.cs(82,82): Error CS1729: The type
SQLite.Net.Cipher.Data.SecureDatabase' does not contain a constructor that takes
2' arguments (CS1729) (Demo)
On this method:
public DemoManager(ISQLitePlatform platform, string dbfile) : base(platform, dbfile)
{
}
Any idea? Can I set the third parameter as null?
Because in my version there's not. You need to pass a third parameter with cryptoservice, that way SaltText is not hardcoded in the library anymore.
This is what i do in PCL:
public MySecureDatabase(ISQLitePlatform platform, string dbfile, ICryptoService cryptoservice) : base (platform, dbfile, cryptoservice)
{
}
protected override void CreateTables()
{
}
ISQLite.cs
ISecureDatabase GetSecureConnection(string saltText);
Then, in you platform specific ISQLite implementation:
public ISecureDatabase GetSecureConnection(string saltText)
{
var path = CopyDatabase(); // in case you ship a pre-made sqlite db
var plat = new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS();
return new MySecureDatabase(plat, path, new CryptoService(saltText)); // third parameter
}
Then use the thing:
using (var conn = DependencyService.Get<ISQLite>().GetSecureConnection(salttext))
{
conn.SecureQuery<T>("SOME SQL", keySeed);
}
I used xamarin forms dependency service in the example but its exactly the same if you use any other dependency injection technique.
I usually save KeySeed and SaltText to KeyChain
private string KeySeed()
{
var keychain = CrossKeyChain.Current.
var keySeed = keychain.GetKey("KeySeed");
if (string.IsNullOrEmpty(keySeed))
{
keySeed = CryptoService.GenerateRandomKey(128) // 16 for saltText
keychain.SetKey("KeySeed", keySeed);
}
return keySeed;
}
Cheers!
Thanks @alexrainman that worked really good. Thanks for sharing that information and I'm glad you were able to remove the hardcoded salt it had before.
The dependencies have been updated and a new version has been pushed, so closing this issue
Hello friends,
I'm wondering if you plan to update this library to support the latest version of PCLCrypto, due when we update it it breaks the application.
Any help is always welcome.
Thanks