Giter Club home page Giter Club logo

Comments (6)

alexrainman avatar alexrainman commented on August 19, 2024

I forked this project and fixed 3 of the issues. I will release it to nuget.

from sqlite.net.cipher.

vhugogarcia avatar vhugogarcia commented on August 19, 2024

Thanks @alexrainman Could you share the link of the new fork you released in nuget, please?

Is that fork compatible with PCLCrypto 2.0?

from sqlite.net.cipher.

vhugogarcia avatar vhugogarcia commented on August 19, 2024

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 takes2' 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?

from sqlite.net.cipher.

alexrainman avatar alexrainman commented on August 19, 2024

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!

from sqlite.net.cipher.

vhugogarcia avatar vhugogarcia commented on August 19, 2024

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.

from sqlite.net.cipher.

has-taiar avatar has-taiar commented on August 19, 2024

The dependencies have been updated and a new version has been pushed, so closing this issue

from sqlite.net.cipher.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.