sha512 static method

Uint8List sha512(
  1. dynamic message, {
  2. int? hashLength,
})

Returns SHA-512 hash of the message.

Implementation

static Uint8List sha512(dynamic message, {int? hashLength}) {
  if (message is String) {
    message = Uint8List.fromList(utf8.encode(message));
  } else if (message is! Uint8List) {
    throw Exception('The message must be either of string or Uint8List');
  }
  final out = Uint8List(defaultHashLength);
  TweetNaCl.crypto_hash(out, message as Uint8List);
  return out.sublist(0, hashLength ?? 64);
}