How to hash SHA-384 in Dart

In this Dart tutorial we learn how to perform SHA-384 hashing in Dart using the crypto library.

Install crypto package in Dart or Flutter

To use the crypto package with Dart, run the following command.

dart pub add crypto

To use the crypto package with Flutter, run the following command.

flutter pub add crypto

The package can be added to your pubspec.yaml as below.

dependencies: 
  crypto: ^3.0.1

How to hash SHA-384 in Dart

In the following Dart program, we use the crypto package to perform SHA-384 hashing which input string ‘toricode.com’ and return hexadecimal digits string as a result of hashing calculation.

import 'package:crypto/crypto.dart';
import 'dart:convert';

void main() {
  var dataToHash = 'toricode.com';

  var bytesToHash = utf8.encode(dataToHash);
  var sha384Digest = sha384.convert(bytesToHash);

  print('Data to hash: $dataToHash');
  print('SHA-384: $sha384Digest');
}
The output as below.
Data to hash: toricode.com
SHA-384: 02600185c82d62c4eccd9ac8164012a0adb50b8d88eab8ab950e2be02419dbe7fa654d0dfac86074d23f29635ab2c7d6

Happy Coding 😊

How to Hash SHA-1 in Dart

How to hash SHA-224 in Dart

How to hash SHA-256 in Dart

How to hash SHA-512 in Dart

How to hash MD5 in Dart