Coder Social home page Coder Social logo

pcsc's Introduction

About

This is the only extension for using PC/SC based smart cards with PHP. It is a wrapper to the wonderful and free project by Ludovic Rousseau, PCSC-Lite, which is the middleware to access a smart card using SCard API (PC/SC). Since PCSC-Lite is compatible to the winscard API it should be possible to compile this extension using a Windows(R) operating system. Currently I only take focus on Linux environments.

Thanks are going to Johann Dantant! He provides a PC/SC extension for PHP since 2005 and I reused some of his code. He allowed me to relicense these parts under the terms of the PHP license so I could integrate PCSC-Lite natively into PHP.

Installation

I recommend to install the PECL extension the "PHP" way:

pecl install pcsc-alpha

You can install the latest version by downloading the sources and compile yourself too... :)

wget http://pecl.php.net/get/pcsc-0.3.1.tgz
tar -xvf pcsc-0.3.1.tgz
cd pcsc-0.3.1
phpize
./configure
make
make install

After that you have all needed files in ./modules/

API

The extension currently provides the following API:

scard_establish_context();

Returns the application $context to the PC/SC resource manager.

scard_is_valid_context($context);

Returns TRUE if $context is valid or FALSE if $context is not valid.

scard_release_context($context);

Releases the application $context.

scard_list_readers($context);

Returns an array of available readers or FALSE.

Example:
array(3) {
  [0]=>
  string(26) "OMNIKEY CardMan 5x21 00 00"
  [1]=>
  string(26) "OMNIKEY CardMan 5x21 00 01"
  [2]=>
  string(76) "SCL01x Contactless Reader [SCL01x Contactless Reader] (21161009200722) 00 00"
}

scard_connect($context, "OMNIKEY CardMan 5x21 00 00");

Connects to a card. Returns the $connection to a reader or FALSE.

scard_reconnect($connection);

Returns the $connection to a reader or FALSE.

scard_disconnect($connection);

Disconnects the $connection to a card. Returns the TRUE if disconnecting was succesful or FALSE.

scard_transmit($connection, $apdu);

Returns the response $apdu as string or FALSE.

scard_status($connection);

Returns the status or FALSE.

scard_cancel($context);

Code

The code has successful been released to the official code repository pecl.php.net... ;)

You could get the code using the following command:

svn checkout http://svn.php.net/repository/pecl/pcsc/trunk pcsc

License

This code is licensed under the terms of the PHP License version 3.01. PCSC-Lite is licensed in a way where it is possible to integrate it native in the PHP environment.

pcsc's People

Contributors

nattynarwhal avatar remicollet avatar hanez avatar weltling avatar

Watchers

James Cloos avatar  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.