Easy PHP ECC: Encrypt, decrypt and sign messages with PHPECC

Recommend this page to a friend!

  Author Author  
Picture of Scott Arciszewski
Name: Scott Arciszewski <contact>
Classes: 30 packages by
Country: United States United States
Age: ???
All time rank: 1299181 in United States United States
Week rank: 8 Up2 in United States United States Up
Innovation award
Innovation award
Nominee: 21x

Winner: 1x


  Detailed description   Download Download .zip .tar.gz  
This package can encrypt, decrypt and sign messages with PHPECC.

It provides wrapper classes around PHPECC package to perform several operations with encrypted messages. Currently it case:

- Generate private key
- Get the public key
- Get the signature for a message using a public key
- Generate data to exchange keys using the private key of the origin and the public key of the destination

Details

Easy-ECC

Build Status Latest Stable Version Latest Unstable Version License Downloads

A usability wrapper for PHP ECC.

Installing

composer require paragonie/easy-ecc

Using Easy-ECC

<?php
use ParagonIE\EasyECC\EasyECC;

// Generate an instance; defaults to Curve25519
$ecc = new EasyECC();

// Get a keypair
$alice_sk = $ecc->generatePrivateKey();
$alice_pk = $alice_sk->getPublicKey();

// Signing a message (with PEM-formatted signatures):
$message = 'This is extremely simple to use correctly.';
$signature = $ecc->sign($message, $alice_sk);

if (!$ecc->verify($message, $alice_pk, $signature)) {
    throw new Exception('Signature validation failed');
}

// Let's do a key exchange:
$bob_sk = $ecc->generatePrivateKey();
$bob_pk = $alice_sk->getPublicKey();

$alice_to_bob = $ecc->keyExchange($alice_sk, $bob_pk, true);
$bob_to_alice = $ecc->keyExchange($bob_sk, $alice_pk, false);

Other Easy-ECC Modes

secp256k1 + SHA256

<?php
use ParagonIE\EasyECC\EasyECC;

$ecc = new EasyECC('K256');

NIST P256 + SHA256

<?php
use ParagonIE\EasyECC\EasyECC;

$ecc = new EasyECC('P256');

NIST P384 + SHA384

<?php
use ParagonIE\EasyECC\EasyECC;

$ecc = new EasyECC('P384');

ECDSA-Specific Features

<?php
use ParagonIE\EasyECC\EasyECC;
use ParagonIE\EasyECC\ECDSA\{PublicKey, SecretKey};

// Generate an instance
$ecc = new EasyECC('P256');

// Get a keypair
/ @var SecretKey $alice_sk */
$alice_sk = $ecc->generatePrivateKey();
/ @var PublicKey $alice_pk */
$alice_pk = $alice_sk->getPublicKey();

// Serialize as PEM (for OpenSSL compatibility):
$alice_sk_pem = $alice_sk->exportPem();
$alice_pk_pem = $alice_pk->exportPem();

// Serialize public key as compressed point (for brevity):
$alice_pk_cpt = $alice_pk->toString();

$message = 'This is extremely simple to use correctly.';
// Signing a message (with IEEE-P1363-formatted signatures):
$signature = $ecc->sign($message, $alice_sk, true);
if (!$ecc->verify($message, $alice_pk, $signature, true)) {
    throw new Exception('Signature validation failed');
}

// Let's do a key exchange:
$bob_sk = $ecc->generatePrivateKey();
$bob_pk = $alice_sk->getPublicKey();

$alice_to_bob = $ecc->keyExchange($alice_sk, $bob_pk, true);
$bob_to_alice = $ecc->keyExchange($bob_sk, $alice_pk, false);

Support Contracts

If your company uses this library in their products or services, you may be interested in purchasing a support contract from Paragon Initiative Enterprises.


  Classes of Scott Arciszewski  >  Easy PHP ECC  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: Easy PHP ECC
Base name: easy-ecc
Description: Encrypt, decrypt and sign messages with PHPECC
Version: -
PHP version: 5
License: MIT/X Consortium License
All time users: Not yet counted
All time rank: Not yet ranked
Week users: Not yet counted
Week rank: Not yet ranked
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Cryptography Encrypting, decrypting and hashing data View top rated classes


  User ratings  
Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (1 file, 4 directories)
Files folder imagetests (4 files, 2 directories)
Accessible without login Plain text file autoload-shim.php Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file psalm.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file ci.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageCurve25519 (5 files)
Files folder imageECDSA (4 files)
Files folder imageException (2 files)
Files folder imageIntegration (1 file)
  Accessible without login Plain text file EasyECC.php Class Class source

  Files folder image Files  /  src  /  Curve25519  
File Role Description
  Accessible without login Plain text file EdwardsPublicKey.php Class Class source
  Accessible without login Plain text file EdwardsSecretKey.php Class Class source
  Accessible without login Plain text file MontgomeryPublicKey.php Class Class source
  Accessible without login Plain text file MontgomerySecretKey.php Class Class source
  Accessible without login Plain text file X25519.php Class Class source

  Files folder image Files  /  src  /  ECDSA  
File Role Description
  Accessible without login Plain text file PublicKey.php Class Class source
  Accessible without login Plain text file PublicKeyDerParser.php Class Class source
  Accessible without login Plain text file SecretKey.php Class Class source
  Accessible without login Plain text file Signature.php Class Class source

  Files folder image Files  /  src  /  Exception  
File Role Description
  Accessible without login Plain text file ConfigException.php Class Class source
  Accessible without login Plain text file NotImplementedException.php Class Class source

  Files folder image Files  /  src  /  Integration  
File Role Description
  Accessible without login Plain text file Defuse.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageECDSA (1 file)
Files folder imageIntegration (1 file)
  Accessible without login Plain text file K256Test.php Class Class source
  Accessible without login Plain text file P256Test.php Class Class source
  Accessible without login Plain text file P384Test.php Class Class source
  Accessible without login Plain text file SodiumTest.php Class Class source

  Files folder image Files  /  tests  /  ECDSA  
File Role Description
  Accessible without login Plain text file SignatureTest.php Class Class source

  Files folder image Files  /  tests  /  Integration  
File Role Description
  Accessible without login Plain text file DefuseTest.php Class Class source

Download Download all files: easy-ecc.tar.gz easy-ecc.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.

For more information send a message to info at phpclasses dot org.