Giter VIP home page Giter VIP logo

enc-example-php's Introduction

Examples Only :)

!) first, import.php to init the key


# php -q import.php
array(9) {
  ["imported"]=>
  int(0)
  ["unchanged"]=>
  int(1)
  ["newuserids"]=>
  int(0)
  ["newsubkeys"]=>
  int(0)
  ["secretimported"]=>
  int(0)
  ["secretunchanged"]=>
  int(0)
  ["newsignatures"]=>
  int(0)
  ["skippedkeys"]=>
  int(0)
  ["fingerprint"]=>
  string(40) "4A64719E367C325BC4680A6804FFDFE6F5146A05"
}



use 'fingerprint' ... 

<?php
/* add location of pub key storage */
putenv ('GNUPGHOME=/tmp');

/* init gnupg */
$res = gnupg_init();

/* select pub key fingerprint */
$rtv = gnupg_addencryptkey($res,'4A64719E367C325BC4680A6804FFDFE6F5146A05');
?>



@) then encrypt.php to encrypt the array and instert into mongodb



ie, encrypt/decrypt

# php -q encrypt.php > test.enc
# gnupg test.enc




Install gnupg module for php
-----------------------------------------


> pecl install gnupg

if you receive an error, see -> https://bugs.php.net/patch-display.php?bug_id=61511&patch=gnupg-1.3.2_PHP54.patch&revision=latest

> pecl download gnupg
> tar xzvf gnupg-1.3.2.tgz
> cd gnupg-1.3.2
> wget -O patch.txt "https://bugs.php.net/patch-display.php?bug_id=61511&patch=gnupg-1.3.2_PHP54.patch&revision=1347037361&download=1"
> patch < patch.txt
> ./configure
> make && make install
add extension=gnupg.so to php.ini






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.