Тёмный

Encrypt Database with SQLite-net and .NET MAUI (or Xamarin.Forms!) 

Gerald Versluis
Подписаться 93 тыс.
Просмотров 11 тыс.
50% 1

In this video we will see how to create and work with a SQLCipher encrypted database in .NET MAUI. The code that is shown will also still work with Xamarin.Forms. I will walk you through the existing code I created in a previous video with the CRUD actions for SQLite and then proceed with how to encrypt your database with sqlite-net-sqlcipher.
💝 Join this channel to get access to perks:
ru-vid.com/show-Geral...
Disclaimer: this channel is done on personal title, in my free time, and not officially affiliated with or endorsed by Microsoft (my employer) in any way. Opinions and views are my own.
🛑 Don't forget to subscribe to my channel for more cool content: ru-vid.com...
🐦 Follow me on Twitter: / jfversluis
🤝 Join the Discord server: / discord
🔗 Links
Sample App Repo: github.com/jfversluis/MauiEnc...
SQLite/SQLCipher compatibility: github.com/praeclarum/sqlite-...
SQLite CRUD Actions Video: • CRUD Operations with S...
⏱ Timestamps
00:00 - Encrypt SQLite Database with .NET MAUI
00:13 - STOP! Do This First...
01:24 - SQLite CRUD App Sample
04:20 - Implement SQLite Encryption
08:02 - A Note About Compatibility
10:53 - What Should I Know More?!
12:00 - Want To Learn More?
🎥 Video edited with Camtasia (ref): techsmith.z6rjha.net/AJoeD
🙋‍♂️ Also find my...
Twitter: / jfversluis
Blog: blog.verslu.is
Twitch: / jfversluis
All the rest: jfversluis.dev
#dotnetmaui #sqlite #encryption #sqlcipher #xamarinforms #localdatabase

Наука

Опубликовано:

 

4 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 63   
@jfversluis
@jfversluis 2 года назад
Want to learn more about setting up SQLite databases first? Check out this video 👉ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-uxqQqyuZ3Qo.html You already set it up but now want to learn how to manipulate data? Day no more, that is in this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-8_cqUvriwM8.html
@Brendan2Alexander
@Brendan2Alexander 2 года назад
Ya done it again Gerald. Another excellent vid thank u!
@jfversluis
@jfversluis 2 года назад
Haha thank you Brendan! Appreciate it!
@CricketThomas
@CricketThomas 2 года назад
Awesome video! Good to know!
@jfversluis
@jfversluis 2 года назад
Thanks for watching!
@iancraig8231
@iancraig8231 Год назад
great video , saved me loads of work thanks
@jfversluis
@jfversluis Год назад
Glad to hear it!
@siddhukhengarekhengare6371
@siddhukhengarekhengare6371 Год назад
Hi Gerald, I'm getting this "Could not install package 'sqlite-net-sqlcipher 1.8.116'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author." at the time of installing.
@MukeshPrajapati-lh7dj
@MukeshPrajapati-lh7dj 2 года назад
Great video... but I think Realm Db is better than sqlite-net and plus it provides an easy encryption as well.
@jfversluis
@jfversluis 2 года назад
🤷‍♂️ There will always be some other tech that others prefer because of reasons... Thanks!
@talia.mcpherson
@talia.mcpherson 6 месяцев назад
How do i check if my sql database has been encrypted after doing all that you mentioned
@NealCuliner
@NealCuliner 2 года назад
I love sqlite-net but I'd like to see more use and demonstration of Microsoft's ORM - Entity Framework Core with .NET MAUI etc. or is there a reason we are to avoid EF Core on mobile apps in 2022?
@jfversluis
@jfversluis 2 года назад
Let me turn it around... Is there any added value in using it? ;)
@NealCuliner
@NealCuliner 2 года назад
@@jfversluis absolutely- working on a context like any ORM. It's time to move on from sqlite-net that has a purpose before EF. Weird seeing Microsoft not embracing their data access system. Almost think it's developer laziness.
@jfversluis
@jfversluis 2 года назад
@@NealCuliner You know that EF is just another layer over an actual database, right? You can still use SQLite underlaying. Additionally please note that I am not Microsoft :)
@Brendan2Alexander
@Brendan2Alexander 2 года назад
I love me the EF Core, but I would think it is better to have something “lite” running on a mobile app no? Now if I was developing for windows or iOS than I would consider going full bore with EF core since there presumably are not any resource constraints
@ghevisartor6005
@ghevisartor6005 Год назад
@@Brendan2Alexander what's the issue with EF Core with sqlite? I've tried them on android and ios and they seems to work fine.
@radutomy
@radutomy 2 года назад
Similarly to other person commenting here, encryption doesn't seem to be working for me either. Steps: I cloned the repo from your github - and used a Pixel 6 as a deployment target instead of Emulator like in your video. The app created the db file `people_encrypted.db3` on my phone, which I pulled over to my laptop, and used SQLite Browser to open it - the data was there in plain sight, no encryption. Any ideas?
@zarokoshin4090
@zarokoshin4090 Год назад
Same here not working :(
@krzysztofb.6396
@krzysztofb.6396 Год назад
I know that answer is late, but someone may read that with a similar problem. For me, it was a different SQLitePCLRaw.bundle_green nuget version to SQLitePCLRaw.bundle_e_sqlcipher used by sqlite-net-sqlcipher. If you use SQLitePCLRaw nugets in your configuration like SQLitePCLRaw.core etc, remember about version compatibility.
@josefredo9514
@josefredo9514 Год назад
Excellent video, do you know any way to use bluetooth with xamarin forms to send and receive messages?
@jfversluis
@jfversluis Год назад
You might want to check out the Shiny plugin for that
@toma1385
@toma1385 2 года назад
The same way we use sqlite in blazor hybrid?
@jfversluis
@jfversluis 2 года назад
Should be the same, yea!
@salisoumoussa
@salisoumoussa 2 года назад
Hello Geralg, I have this type of problem in Xamarin MSB6006; "java.exe" ended with code 2. Can you help me please? thank you
@jfversluis
@jfversluis 2 года назад
Based on this info it's hard to provide any answer. There is an underlaying error message somewhere. Make sure to have a good look at the build output.
@serjdukareff7198
@serjdukareff7198 Год назад
I have checked the example project and the database does not actually get encrypted in it. To make it work at .csproj file all the SQLitePCLRaw.* dependencies should be changed to SQLitePCLRaw.lib.sqlcipher..
@prabakaranr4757
@prabakaranr4757 8 месяцев назад
The local db is created via azure offline sync. But we want to encrypt that local db. What do you suggest?
@jfversluis
@jfversluis 8 месяцев назад
Depends on the data. If there is sensitive stuff in there, always encrypt!
@prabakaranr4757
@prabakaranr4757 8 месяцев назад
Thanks for the quick reply. The data is sensitive. We need to encrypt it. But we cannot find a way to encrypt it without any paid 3rd party library. The solution you have mentioned is not working with azure offline sync local db. Do you know any solution to encrypt the db file that is created from azure offline sync?
@julojenis8181
@julojenis8181 2 года назад
Hi Gerald, this is super video. I have one question. How can I backup (or export) my SQLite db stored in Environment.SpecialFolder.LocalApplicationData? Thanks for all tips.
@jfversluis
@jfversluis 2 года назад
Since it’s just a file, copy it there 😉
@gfmoore
@gfmoore 2 года назад
​@@jfversluis Great vid. However, where exactly on the device is that folder. I'm using Android Studio and a Pixel 5 emulator and using Device File Explorer. There's hundreds of folders and I can't see a search option. Grateful for any help. :)
@gfmoore
@gfmoore 2 года назад
Ahh don't worry. I eventually got to /data/data/uk.co.xxxxx.myappname/files/.local/xyz.db3 :)
@EthanHipps
@EthanHipps 2 года назад
What is your opinion on LiteDB vs SQLite for .NET MAUI apps?
@jfversluis
@jfversluis 2 года назад
Don’t have a strong opinion tbh I think both do roughly the same with the same performance
@EthanHipps
@EthanHipps 2 года назад
@@jfversluis Thanks for the reply! I decided to go ahead and give LiteDB a shot, so I'll let you know how it goes.
@jfversluis
@jfversluis 2 года назад
@@EthanHipps oh I have tried it with .NET MAUI. Both of them, they work! So that’s something 😄
@anubhavtyagi4417
@anubhavtyagi4417 2 года назад
My database is not get encrypted, when I tried to pull with ads command and open with Chrome Sql viewer, I can see the DB data. Could you please help here.
@jfversluis
@jfversluis 2 года назад
That is kind of impossible without knowing your project :)
@kratichauhan3451
@kratichauhan3451 Год назад
I had the same problem. I renamed the DB and tried, and it worked for me.
@codigoadictivo
@codigoadictivo 2 года назад
can this also be done with blazor or maui blazor when using sqlite database?
@jfversluis
@jfversluis 2 года назад
Absolutely! That makes no difference:)
@codigoadictivo
@codigoadictivo 2 года назад
@@jfversluis good news. thanks
@yaser107
@yaser107 2 года назад
please how to connect dotnet maui to sqlserver direct connection i have this error A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 31 - Encryption(ssl/tls) handshake failed)' i have tried every thing
@jfversluis
@jfversluis 2 года назад
Looks like something is wrong with the secure connection. Does the server accept secure connections? Is the certificate expired?
@yaser107
@yaser107 2 года назад
@@jfversluis the server works fine in xamarian using system.data.sqlclient and i have tried to use microsoft.data.sqlclient workes fine on blazor but not working in maui or xamarain the server has no ssl instaled
@jfversluis
@jfversluis 2 года назад
@@yaser107 It's kind of hard to debug without being able to try or see anything... Sorry!
@SoftAsInSoftware
@SoftAsInSoftware 2 года назад
So where do you store your encryption password? #chickenegg As you know, storing your 'secret' in the client app is just as vulnerable as having no encryption (this is also one of the things to keep in mind when you use Blazor WASM).
@jfversluis
@jfversluis 2 года назад
Yep absolutely true! Ideally you probably want to get that from Azure KeyVault maybe? Or you can retrieve it once from a remote service and save it in the secure storage of the device or even generate a unique one per device. Good question, I should've mentioned that 😬
@BurkusCat
@BurkusCat 2 года назад
@@jfversluis Or you could use a user-entered PIN/password or biometrics as the encryption password. Not stored on the device or in the cloud.
@jfversluis
@jfversluis 2 года назад
The biometrics isn’t much more than an automated/easier way to get a value (pin or password) from the secure storage and enter it for you. But definitely a good idea to add!
@codigoadictivo
@codigoadictivo 2 года назад
@@jfversluis does the browsers also have a secure storage file as mobiles does to store important things? because for my mobile app i can use the secure storage of the devise, but what about to the web app where to store it?
@SheikhMuhammadNawaz
@SheikhMuhammadNawaz Год назад
How to use it with C# and SQLite .db file?
@jfversluis
@jfversluis Год назад
Should be the exact same
@SheikhMuhammadNawaz
@SheikhMuhammadNawaz Год назад
@@jfversluis Can you please make an another tutorial regarding this?
@jfversluis
@jfversluis Год назад
Not sure what you need because like I said: it should be the exact same
@SheikhMuhammadNawaz
@SheikhMuhammadNawaz Год назад
@@jfversluis I have Window form application in C# with SQLite as backend.
@shaikeesa8015
@shaikeesa8015 Месяц назад
STRUCTURE: I am using xamarin.forms and cocoa app(xamarin.mac) in integration with it. My xamarin.forms deals with all the UI and cocoa app(xamarin.mac) does interaction with all the mac api's . I have a seperate class library which handles all the database part. all of these projects builds sucessfully when i build them individually the moment i set my xamarin.mac project as my start up and run the application it throws the following error at the line new SQLiteAsyncConnection(connectionstring) ERROR: System.DLLNotFoundException: e_sqlcipher assembly: type: member:(null) This error comes in my classlibrary. NOTE: There is no code involved in the xamarin.forms or xamain.mac that would need the package sqlite-net-sqlcipher to be installed in them. so i have downloaded that package only in the classlibrary.
@codigoadictivo
@codigoadictivo 2 года назад
.GetFolderPath(Environment.SpecialFolder is not working in blazor, where should we save the sqlite database when using blazor?
@codigoadictivo
@codigoadictivo 2 года назад
i think the problem is the this sqlite-net-pcl or the encripted one does not work in blazor because of some dll: System.DllNotFoundException: e_sqlite3 which needs to be loaded manually or something like that :S
@jfversluis
@jfversluis 2 года назад
Do you mean Blazor for the web or .NET MAUI Blazor?
@codigoadictivo
@codigoadictivo 2 года назад
​@@jfversluis I am using blazor webassembly to build an amazon clone with blazor , but when NET MAUI Blazor is ready for production i will migrate all the code to make the same app but in mobile. and i was trying to use the sqlite-net-pcl to store data locally in the web app, but i seems it does not work in blazor web because of some dll: System.DllNotFoundException: e_sqlite3 which needs to be laded as < NativeReference Include="Data/e_sqlite3 " / > or something like that which seem to be complicated jeje. could you talk with the onwers of the sqlite-net-pcl nugget package so they can make it work with blazor web also? it would be so nice, in that way I would not have to use two system to store data locally like: localstorage for the web app and sqlite for the mobile app. mean while i think i will have to use the browser local storage functionality to store data locally for the blazor web app.
Далее
Encrypt SQLite Databases with SQLCipher
14:58
Просмотров 13 тыс.
DHH discusses SQLite (and Stoicism)
54:00
Просмотров 57 тыс.
КАКОЙ SAMSUNG КУПИТЬ В 2024 ГОДУ
14:59