Search packages, repositories and app categories

Package detailsv1.0.0

crypto_keys_plus

A library for doing cryptographic signing/verifying and encrypting/decrypting.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
80.2K
Likes
3
Pub points
150

Install package

flutter pub add crypto_keys_plus

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter/Dart package designed for cryptographic operations such as signing, verifying, encrypting, and decrypting data. It provides a secure and cross-platform solution for handling sensitive information across Android, iOS, Web, macOS, Windows, and Linux. Built with simplicity in mind, it enables developers to implement robust security features without deep expertise in cryptography. The library leverages underlying native cryptographic APIs where available, ensuring performance and compliance with platform-specific security standards.

Use cases

  • Secure data transmission
  • Digital signature verification
  • End-to-end encryption
  • Authentication token protection
  • Secure local storage of sensitive data
  • Compliance with data privacy regulations

Key features

  • Cross-platform cryptographic support
  • Simple API for signing and encryption
  • Integration with native crypto libraries
  • Support for multiple platforms
  • Secure key management
  • Open-source and actively maintained

Suitable for

  • Developers building secure apps
  • Apps requiring data integrity
  • Applications handling user authentication
  • Projects needing encrypted communication
  • Teams prioritizing compliance and security

Considerations

  • Requires understanding of basic cryptography concepts
  • Depends on platform-specific crypto implementations
  • Not suitable for high-performance cryptographic workloads
  • Key management best practices must be followed
  • Limited documentation beyond basic usage

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Build Status :heart: sponsor

A library for doing cryptographic signing/verifying and encrypting/decrypting.

It uses pointycastle under the hood, but exposes a more convenient api.

Usage

Signing

A simple usage example:

import 'package:crypto_keys/crypto_keys.dart';
import 'dart:typed_data';

main() {
  // Create a key pair from a JWK representation
  var keyPair = new KeyPair.fromJwk({
    "kty": "oct",
    "k": "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75"
        "aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow"
  });

  // A key pair has a private and public key, possibly one of them is null, if
  // required info was not available when construction
  // The private key can be used for signing
  var privateKey = keyPair.privateKey;

  // Create a signer for the key using the HMAC/SHA-256 algorithm
  var signer = privateKey.createSigner(algorithms.signing.hmac.sha256);

  // Sign some content, to be integrity protected
  var content = "It's me, really me";
  var signature = signer.sign("It's me, really me".codeUnits);

  print("Signing '$content'");
  print("Signature: ${signature.data}");

  // The public key can be used for verifying the signature
  var publicKey = keyPair.publicKey;

  // Create a verifier for the key using the specified algorithm
  var verifier = publicKey.createVerifier(algorithms.signing.hmac.sha256);

  var verified =
      verifier.verify(new Uint8List.fromList(content.codeUnits), signature);
  if (verified)
    print("Verification succeeded");
  else
    print("Verification failed");
}
Encryption

A simple usage example:


import 'package:crypto_keys/crypto_keys.dart';
import 'dart:typed_data';

main() {
  // Generate a new random symmetric key pair
  var keyPair = new KeyPair.generateSymmetric(128);

  // Use the public key to create an encrypter with the AES/GCM algorithm
  var encrypter =
      keyPair.publicKey.createEncrypter(algorithms.encryption.aes.gcm);

  // Encrypt the content with an additional authentication data for integrity
  // protection
  var content = "A very secret text";
  var aad = "It is me";
  var v = encrypter.encrypt(new Uint8List.fromList(content.codeUnits),
      additionalAuthenticatedData: new Uint8List.fromList(aad.codeUnits));

  print("Encrypting '$content'");
  print("Ciphertext: ${v.data}");
  print("Authentication tag: ${v.authenticationTag}");

  // Use the private key to create the decrypter
  var decrypter =
      keyPair.privateKey.createEncrypter(algorithms.encryption.aes.gcm);

  // Decrypt and verify authentication tag
  var decrypted = decrypter.decrypt(v);

  print("Decrypted text: '${new String.fromCharCodes(decrypted)}'");
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Sponsor

Creating and maintaining this package takes a lot of time. If you like the result, please consider to :heart: sponsor. With your support, I will be able to further improve and support this project.

Categories

Dependencies

Dependency list 4 items

Source repository

Projects using this package