Search packages, repositories and app categories

Package detailsv3.10.7

openpgp

library for use OpenPGP with support for android and ios, macOS, linux, windows and web

AndroidiOSWebmacOSWindowsLinux
30-day downloads
6K
Likes
44
Pub points
100

Install package

flutter pub add openpgp

Package Overview

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

A Flutter/Dart package that enables OpenPGP encryption and decryption across multiple platforms, including Android, iOS, web, macOS, Windows, and Linux. It provides a secure way to handle cryptographic operations such as signing, verifying, encrypting, and decrypting data using OpenPGP standards. Designed for developers needing cross-platform cryptographic functionality in their apps, it integrates seamlessly with existing workflows. The library is maintained by jerson.dev and supports both mobile and desktop environments.

Use cases

  • Secure messaging applications
  • Data encryption for offline storage
  • Digital signatures for document integrity
  • Cross-platform secure file transfer
  • User authentication with encrypted tokens

Key features

  • Supports all major operating systems
  • Full OpenPGP standard compliance
  • Easy integration with Flutter projects
  • Cross-platform key management
  • Built-in encryption and decryption utilities

Suitable for

  • Developers building secure communication tools
  • Apps requiring end-to-end encryption
  • Projects needing digital signature support
  • Multi-platform cryptography implementations
  • Privacy-focused applications

Considerations

  • Requires understanding of OpenPGP concepts
  • Key management must be handled securely by the app
  • Performance may vary on low-end devices
  • Limited documentation beyond basic usage
  • Not suitable for high-frequency cryptographic operations without optimization

Original README

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

OpenPGP

Library for use openPGP with support for android, ios, macos, windows, linux and web

Integration Tests Android

Integration Tests Linux

Integration Tests Windows

Integration Tests iOS

Integration Tests macOS

Contents

Usage

Async methods
Generate methods

void main() async {
    var keyOptions = KeyOptions()..rsaBits = 2048;
    var keyPair = await OpenPGP.generate(
            options: Options()
              ..name = 'test'
              ..email = 'test@test.com'
              ..passphrase = passphrase
              ..keyOptions = keyOptions);
}
Encrypt methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.encrypt("text","[publicKey here]");
    var result = await OpenPGP.encryptSymmetric("text","[passphrase here]");
    var result = await OpenPGP.encryptBytes(bytesSample,"[publicKey here]");
    var result = await OpenPGP.encryptSymmetricBytes(bytesSample,"[passphrase here]");

}

Decrypt methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.decrypt("text encrypted","[privateKey here]","[passphrase here]");
    var result = await OpenPGP.decryptSymmetric("text encrypted","[passphrase here]");
    var result = await OpenPGP.decryptBytes(bytesSample,"[privateKey here]","[passphrase here]");
    var result = await OpenPGP.decryptSymmetricBytes(bytesSample,"[passphrase here]");

}
Sign methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.sign("text","[privateKey here]","[passphrase here]");
    var result = await OpenPGP.signBytesToString(bytesSample,"[privateKey here]","[passphrase here]");
    
    // sign including data
    var result = await OpenPGP.signData("text","[privateKey here]","[passphrase here]");
    var result = await OpenPGP.signDataBytesToString(bytesSample,"[privateKey here]","[passphrase here]");

}

Verify methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.verify("text signed","text","[publicKey here]");
    var result = await OpenPGP.verifyBytes("text signed", bytesSample,"[publicKey here]");
    
    // verify signed with data
    var result = await OpenPGP.verifyData("text signed","[publicKey here]");
    var result = await OpenPGP.verifyDataBytes(bytesSample,"[publicKey here]");

}

Encode methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = await OpenPGP.armorEncode("PGP MESSAGE", bytesSample);
}

Decode methods

void main() async {    
    var result = await OpenPGP.armorDecode("message here");
}

Metadata methods

void main() async {
    var result = await OpenPGP.getPrivateKeyMetadata("[privateKey here]");
    var result = await OpenPGP.getPublicKeyMetadata("[publicKey here]");
}

Convert methods

void main() async {
    var result = await OpenPGP.convertPrivateKeyToPublicKey("[privateKey here]");
}

Sync methods
Generate methods

void main() {
    var keyOptions = KeyOptions()..rsaBits = 2048;
    var keyPair = OpenPGPSync.generate(
            options: Options()
              ..name = 'test'
              ..email = 'test@test.com'
              ..passphrase = passphrase
              ..keyOptions = keyOptions);
}
Encrypt methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = OpenPGPSync.encrypt("text","[publicKey here]");
    var result = OpenPGPSync.encryptSymmetric("text","[passphrase here]");
    var result = OpenPGPSync.encryptBytes(bytesSample,"[publicKey here]");
    var result = OpenPGPSync.encryptSymmetricBytes(bytesSample,"[passphrase here]");

}

Decrypt methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = OpenPGPSync.decrypt("text encrypted","[privateKey here]","[passphrase here]");
    var result = OpenPGPSync.decryptSymmetric("text encrypted","[passphrase here]");
    var result = OpenPGPSync.decryptBytes(bytesSample,"[privateKey here]","[passphrase here]");
    var result = OpenPGPSync.decryptSymmetricBytes(bytesSample,"[passphrase here]");

}
Sign methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = OpenPGPSync.sign("text","[privateKey here]","[passphrase here]");
    var result = OpenPGPSync.signBytesToString(bytesSample,"[privateKey here]","[passphrase here]");
    
    // sign including data
    var result = OpenPGPSync.signData("text","[privateKey here]","[passphrase here]");
    var result = OpenPGPSync.signDataBytesToString(bytesSample,"[privateKey here]","[passphrase here]");

}

Verify methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = OpenPGPSync.verify("text signed","text","[publicKey here]");
    var result = OpenPGPSync.verifyBytes("text signed", bytesSample,"[publicKey here]");
    
    // verify signed with data
    var result = OpenPGPSync.verifyData("text signed","[publicKey here]");
    var result = OpenPGPSync.verifyDataBytes(bytesSample,"[publicKey here]");

}

Encode methods

void main() async {
    var bytesSample = Uint8List.fromList('data'.codeUnits);
    
    var result = OpenPGPSync.armorEncode("PGP MESSAGE", bytesSample);
}

Decode methods

void main() async {    
    var result = OpenPGPSync.armorDecode("message here");
}

Metadata methods

void main() async {
    var result = OpenPGPSync.getPrivateKeyMetadata("[privateKey here]");
    var result = OpenPGPSync.getPublicKeyMetadata("[publicKey here]");
}

Convert methods

void main() async {
    var result = OpenPGPSync.convertPrivateKeyToPublicKey("[privateKey here]");
}

Setup

Android

No additional setup required.

iOS

No additional setup required.

Web

Add to you pubspec.yaml.

assets:
    - packages/openpgp/web/assets/worker.js
    - packages/openpgp/web/assets/wasm_exec.js
    - packages/openpgp/web/assets/openpgp.wasm

ref: https://github.com/jerson/flutter-openpgp/blob/master/example/pubspec.yaml

MacOS

No additional setup required.

Linux

No additional setup required.

Windows

No additional setup required.

Example

Inside example folder.

cd example && flutter run

check our web demo: [https://flutter-openpgp.jerson.dev/]

Native Code

Native library is made in Go for faster performance.

[https://github.com/jerson/openpgp-mobile]

Upgrade Library

You need to run

make upgrade

Tests

You need to run

make test

Categories

Dependencies

Dependency list 5 items

Source repository

Projects using this package