Sha512 class abstract
SHA-512 HashAlgorithm (sometimes called SHA2-512).
In browsers, the default implementation will use Web Cryptography API. On other platforms, DartSha512 will be used.
Asynchronous usage (recommended)
import 'package:cryptography/cryptography.dart';
Future<void> main() async {
final message = <int>[1,2,3];
final algorithm = Sha512();
final hash = await algorithm.hash(message);
print('Hash: ${hash.bytes}');
}
If you really need synchronous computations, use DartSha512.
Streaming usage
This enables you to handle very large inputs without keeping everything in memory:
import 'package:cryptography/cryptography.dart';
void main() async {
// Create a sink
final algorithm = Sha512();
final sink = algorithm.newSink();
// Add any number of chunks
sink.add(<int>[1,2,3]);
sink.add(<int>[4,5]);
// Calculate the hash
sink.close();
final hash = await sink.hash();
print('Hash: ${hash.bytes}');
}
- Inheritance
-
- Object
- HashAlgorithm
- Sha512
- Implementers
Constructors
- Sha512()
-
factory
- Sha512.constructor()
-
Constructor for classes that extend this class.
const
Properties
- blockLengthInBytes → int
-
The internal block size in bytes. This information is required by some
algorithms such as Hmac.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setteroverride
- hashLengthInBytes → int
-
Digest size in bytes.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
hash(
List< int> input) → Future<Hash> -
Calculates hash for the argument.
inherited
-
newHashSink(
) → HashSink -
Constructs a sink for hashing chunks.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
toSync(
) → DartHashAlgorithm -
For synchronous computations, returns a pure Dart implementation of the
hash algorithm.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override