How can I store the set pattern lock in flutter?

64 views Asked by At

I want to set own pattern lock in my flutter app and want to open the app later with same lock . I'm using a pattern lock plugin to set the pattern. How can I store the pattern/pin lock ?

I thought to use shared preferences plugin but didn't understand how to use it ? I'm expecting to use the set pattern lock when I open my Flutter app next time. So how can I securely store and retrieve it ?

1

There are 1 answers

2
Jesutoni On

While storing the pattern directly in Shared Preferences is not recommended due to security concerns, here's a secure approach to achieve your goal:

  1. Secure Storage:

Use a secure storage plugin like flutter_secure_storage or key_value_store. These plugins offer encrypted storage and access control mechanisms. 2. Pattern Hashing:

Instead of storing the actual pattern, generate a unique hash of the pattern using a strong hashing algorithm like SHA-256 or Argon2. This ensures the pattern itself is never stored in plain text. 3. Storage and Retrieval:

When the user sets the pattern: Hash the pattern. Store the hash in the secure storage plugin. When the user attempts to unlock the app: Retrieve the stored hash. Generate a new hash from the entered pattern. Compare the two hashes. If they match, unlock the app.