GithubHelp home page GithubHelp logo

php-crypto's Introduction

PHP Crypto library

Build Status

You will find the integration of :

This library is created for the gaspSync projet

unit Test

This library use the codeception tools.

I have implemented the common test vector.

composer dump-autoload
codecept run

The test vector will fail for now, they are in comment but present in test file :

  • test scrypt vector 4
  • test scrypt vector 5
  • test scrypt vector6
  • test scrypt vector7
  • test scrypt vector4

Sign / check signature

Function definition :

public function sign($privateKeyPem,$data,$signature_alg=OPENSSL_ALGO_DSS1)
public function verifySign($publicKeyPem,$data,$signature,$signature_alg=OPENSSL_ALGO_DSS1){

Expand function

$hkdf = \Crypto\Crypto::HKDF($secretToken, $hashmode,null,$hashmod_digest_size,self::HKDF_INFO_SIGNING);

rfc5869 : HKDF

$scrypt =  \Crypto\Crypto::myScrypt($password, $salt,64*1024, 8, 1, 32);
  • the function do a hex2bin() for the $password and $salt.
  • the function will use DomBlack PHP module if available (don't forget to add it to command line for the tests)
  • pbkdf2 function
$crypto = new \Crypto\Crypto();
$key = $crypto->Pbkdf2($hash, $pass=null, $salt=null, $iterations, $length)
  • Diverse function :
  function hexdecKey($arrayKey){
  function bchexdec($hex)
  function bcdechex($number)

Key manipulation

  • Creating private / public key DSA (can be used for the sign / verifySign function):
\CryptoCrypto::generateNewDSAKey('./keyDirectory');
  function addPublicHeaderFooter($Key)
  function removeHeaderFooter($pemKey)
  function PemToDer($Pem)
  function DerToKey($der)
  function viewPEMElement($PEMKey)
  function make_printable($result, $i = 0)
  function print_line($start, $depth, $length, $headerlength, $constructed, $type, $extra = false)

Copyright

When not explicitly set, files are placed under a 3 clause BSD license

php-crypto's People

Contributors

vinpel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.