KeyPair class

Platform-agnostic RSA key pair representation.

This class provides a simple, serializable representation of an RSA key pair using PEM-encoded strings. Unlike platform-specific implementations (e.g., fast_rsa.KeyPair), this class can be safely used across all platforms including web workers and isolates.

Usage

final keyPair = KeyPair(
  '-----BEGIN PUBLIC KEY-----...',
  '-----BEGIN PRIVATE KEY-----...',
);

Security

The private key should be treated as sensitive data and handled securely:

  • Never log or display private keys
  • Store securely using platform-appropriate secure storage
  • Transfer only within trusted boundaries (same application)

Constructors

KeyPair(String publicKey, String privateKey)
Creates a key pair from PEM-encoded strings.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
privateKey String
RSA private key in PEM format (PKCS#8).
final
publicKey String
RSA public key in PEM format (PKCS#8).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited