crypter 0.1.1 copy "crypter: ^0.1.1" to clipboard
crypter: ^0.1.1 copied to clipboard

Encrypt data, decrypt data, hash stuff and validate hashes (using encrypt package and crypto package)

example/main.dart

import 'dart:typed_data';

import 'package:crypter/crypter.dart';

void main() {
  /// Some data
  var data = Uint8List.fromList(List.generate(256, (i) => i));

  /// A key
  var key = 'ksajog9243shd42l9ds42';

  /// Hash the data (automatically generates salt that is included in the hash)
  var hash = Crypter.hash(data);

  /// Encrypt the data
  var encrypted = Crypter.encrypt(data, key);

  /// Decrypting with the wrong key
  Crypter.decrypt(data, 'aslkdf');

  /// Decrypting with the correct key
  var decrypted = Crypter.decrypt(encrypted, key);

  /// The hash should equal
  assert(Crypter.checkHash(decrypted, hash));

  /// Note that the manual hashing here is not needed for encryption/decryption since the encrypted also contains a hash of the original object
}
0
likes
40
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

Encrypt data, decrypt data, hash stuff and validate hashes (using encrypt package and crypto package)

Homepage
Repository (GitHub)

License

MIT (license)

Dependencies

crypto, encrypt

More

Packages that depend on crypter