Ad

How To Encrypt Password While Saving In Database In Flutter-SQLite-Dart Application?

I'm developing a mobile application using Flutter, Dart and SQLite. It is just a Login page validation kind of project where I need to encrypt the password and user's personal details while inserting in the database. At least I want the password to be encrypted. How is it possible to achieve this?

Ad

Answer

I've used cryptographic hashing functions for Dart and it works fine for me.

The below code is what I used to hash the password.

import 'package:crypto/crypto.dart';
import 'dart:convert'; // for the utf8.encode method

void main() {
  var bytes = utf8.encode("password"); // data being hashed

  var digest = sha256.convert(bytes);

  print("Digest as bytes: ${digest.bytes}");
  print("Digest as hex string: $digest");
}

Ad
source: stackoverflow.com
Ad