WebFaction
Community site: login faq

https://wiki.php.net/rfc/mcrypt-viking-funeral - mcrypt may be removed in PHP 7.1.
So I was wondering what other simpler methods are there to use encrpytion in PHP ?

asked 31 Mar '16, 13:13

anjanesh
78927
accept rate: 16%


Libsodium seems to be picking up some speed as an mcrypt alternative.

You can install it manually by compiling its source.

Here's what I did to install the library:

mkdir -p ~/tmp ~/opt/libsodium
cd ~/tmp
wget https://github.com/jedisct1/libsodium/releases/download/1.0.8/libsodium-1.0.8.tar.gz
tar xvzf libsodium-1.0.8.tar.gz
cd libsodium-1.0.8/
./configure --prefix=$HOME/opt/libsodium
make
make install

To install the php binding you need to do the following:

mkdir -p $HOME/php70-exts
cd ~/tmp
wget https://github.com/jedisct1/libsodium-php/archive/1.0.2.tar.gz
tar xvzf 1.0.2.tar.gz
cd libsodium-php-1.0.2/
phpize70
vi configure # add /home/your_username/opt/libsodium in the SEARCH_PATH variable around line 4099
./configure --with-libsodium --with-php-config=/usr/local/bin/php70-config
make
cp modules/libsodium.so $HOME/php70-exts
ln -s /usr/local/lib/php70/extensions/no-debug-non-zts-20151012/* $HOME/php70-exts
echo "extension_dir = $HOME/php70-exts" >> $HOME/webapps/<you_php70_app>/php.ini
echo "extension = libsodium.so" >> $HOME/webapps/<your_php70_app>/php.ini

You should now be able to see the library being loaded with a call to phpinfo():

$ php70 -c php.ini -i | grep sodium
libsodium support => enabled
libsodium headers version => 1.0.8
libsodium library version => 1.0.8
permanent link

answered 31 Mar '16, 14:47

iliasr ♦♦
2.1k14
accept rate: 35%

edited 31 Mar '16, 14:48

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×4

question asked: 31 Mar '16, 13:13

question was seen: 7,694 times

last updated: 31 Mar '16, 14:48

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM