fromBase64toSha256 method

String fromBase64toSha256(
  1. String value
)

Converts given Base64 String to SHA-256 format String.

Throws FormatException if given value cannot be a valid SHA-256 hash.

Returns base64 encoded String.

Implementation

String fromBase64toSha256(String value) {
  final List<int> bytes = base64.decode(value);
  final hexForm = hex.encode(bytes);

  if (!isValidSha256Format(hexForm)) {
    throw const FormatException('Value is not SHA-256');
  }

  final sha256Form = _formatSha(hexForm);
  return sha256Form;
}