Store Data Securely with Hive — Flutter

Bittu Patel
1 min readApr 9, 2021

--

Sometimes it is necessary to store data securely on disk. Hive supports AES-256 encryption out of the box.

Introduction

The only thing you need is a 256-bit (32-byte) encryption key. Hive provides a helper function to generate a secure encryption key using the random number generator called Fortuna.

Generate Secure Key

To secure data, we need to generate an encryption key. We store the encryption key using the flutter_secure_storage package, but you can use any package/method to securely store the encryption key.

Encrypted Box

Now we have generated an encryption key that we need to pass as a parameter encryptionCipher to the method Hive.openBox().

The End

Congratulations, you have finished this tutorial where you learned how to encrypt your boxes using the AES-256 encryption provided by Hive.

Do you want to learn more about Hive?

Let us know in the comments below.

www.developerb2.com

--

--

Bittu Patel

Expertise in Frontend, Backend, and Everything in Between