You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# examples/quickstart.rbrequire"ecies"# Generate a secret keysk=Ecies.generate_keyraw_sk=Ecies.decode_hex(sk.send(:serialize))raw_pk=sk.pubkey.serialize(compressed: false)# Encrypt data with the receiver's public keyplaintext="Hello, World!"encrypted=Ecies.encrypt(raw_pk,plaintext)# Decrypt data with the receiver's secret keydecrypted=Ecies.decrypt(raw_sk,encrypted)putsdecrypted# => "Hello, World!"
Sponsors
Configuration
You can customize the encryption behavior using a Config object:
# examples/config.rbrequire"ecies"Ecies::DEFAULT_CONFIG.is_ephemeral_key_compressed=true# Use compressed ephemeral public keyEcies::DEFAULT_CONFIG.is_hkdf_key_compressed=true# Use compressed key for HKDFEcies::DEFAULT_CONFIG.symmetric_nonce_length=16# Nonce length for AES-GCM (default: 16)
Configuration Parameters
is_ephemeral_key_compressed (Boolean): Whether to use compressed format for the ephemeral public key. Default: false
is_hkdf_key_compressed (Boolean): Whether to use compressed format for HKDF key derivation. Default: false
symmetric_nonce_length (Integer): The nonce length for AES-GCM encryption. Options: 12, 16. Default: 16