libsodium-php | The PHP extension for libsodium | Cryptography library
kandi X-RAY | libsodium-php Summary
kandi X-RAY | libsodium-php Summary
A simple, low-level PHP extension for [libsodium] Requires libsodium >= 1.0.9 and PHP 7.{0,1,2,3,4}.x or PHP 8.0.x. Full documentation here: [Using Libsodium in PHP Projects] a guide to using the libsodium PHP extension for modern, secure, and fast cryptography.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of libsodium-php
libsodium-php Key Features
libsodium-php Examples and Code Snippets
Community Discussions
Trending Discussions on libsodium-php
QUESTION
I have installed libsodium and libsodium-php on ubuntu 16.04 but when I run:
...ANSWER
Answered 2017-Jul-15 at 23:45The PHP API for libsodium has changed in version 2.0.0 of the extension.
Originally, all functions were in a \Sodium\
namespace.
However, following a vote by PHP developers regarding its inclusion in PHP 7.2, it was decided to move everything to the global namespace instead.
So, what used to be \Sodium\library_version_major()
is now sodium_library_version_major()
.
QUESTION
Sorry if this is a repeat but the few close questions I have found have not worked for me. I am a Laravel newbie. I am trying to use the github library https://github.com/google/google-api-php-client with laravel 5.6 framework.
I installed the api by running:
composer require google/apiclient:^2.0
My composer.json looks correct since it includes:
...ANSWER
Answered 2018-Apr-03 at 22:10If a class is not in any namespace, you can reference from inside a namespace by prefixing it with a leading \
, as in $foo = new \Google_Client;
Meanwhile, the string you specify in a use
statement isn't a "path" as such, it's just the "fully-qualified class name", that is, the class name with its namespace included on the front. So for a class in no namespace, it's just the name, use Google_Client;
QUESTION
I'm working on the encryption using libsodium my problem is the decryption part, its not going through and displaying error.
Fatal error: Uncaught SodiumException: ops limit must be greater than 0 in C:\xampp\htdocs\encrypter\decrypt.php:18 Stack trace: #0 C:\xampp\htdocs\encrypter\decrypt.php(18): sodium_crypto_pwhash() #1 {main} thrown in C:\xampp\htdocs\encrypter\decrypt.php on line 18
I tried to copy some lines in the encryption code but didn't work.
I also receive warning.
But I don't know if this is the cause. I also receive this on encryption.
Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in C:\xampp\htdocs\encrypter\decrypt.php on line 11
Warning: unpack(): 64-bit format codes are not available for 32-bit versions of PHP in C:\xampp\htdocs\encrypter\decrypt.php on line 12
UPDATE
The warning is fixed by changing the pack() code from
P
toV
.Upon changing the code the
$opslimit
has a value more than 0.
DECRYPTION CODE
...ANSWER
Answered 2019-Feb-08 at 12:24The code was indeed not designed for 32 bit versions of PHP.
If you change P
to V
, you need to:
- Do it both in calls to
unpack()
and calls topack()
- Change the number of bytes read/written from 8 to 4.
But the best thing to do would actually be trying to understand what the code does.
It stores the memory limit and iterations at the beginning of the file, so that these parameters can be recovered later when reading the file, without having to hard-code them.
pack()
encodes a value in a fixed number of bytes. unpack()
does the opposite.
pack('P')
encodes a 64 bit value into 8 bytes. unpack('P')
reads 8 bytes and converts them into a value.
If your environment doesn't support 64 bit values, pack/unpack to 4 bytes, but you then need to write 4 bytes, not 8. And read 4 bytes as well, not 8.
QUESTION
I want to connect to ssh via PHP. I can do that easily but the problem is the integrity of the login details (username, password). When I first tried the code I stored my username and password in plain sight. I thought about encrypting those variables. By looking at other questions I found libsodium
: https://github.com/jedisct1/libsodium-php
I am using their first example of encrypting a string:
...ANSWER
Answered 2018-Mar-04 at 13:25Nothing is totally bulletproof. Anyway, this is far from it. It's your implementation that lacks. First you encrypt it, but then you store the encrypted message along with the secret key in a database.
This is all that's required to decrypt it. So any SQL injection flaws OR server/database breaches could compromise the encrypted messages and render it useless. Don't store the private key on the server; especially not with it's intended message. It's nothing more than expensive cleartext if you do that.
Don't even store the database connection file in the web root. It's trivial for an hacker to grab that way, look up LFI. You can store it outside e.g. in /var/www/ and serve your index.php from /var/www/public/.
As noted in the comments, it's a little odd what you're doing here anyway. You'd probably be much better off using SSH keys with a pass phrase.
QUESTION
I can't figure out how to get Libsodium up and running on my EC2 instance.
When attempting to check if the installation was successful with:
...ANSWER
Answered 2017-Oct-26 at 07:53Same on alpine and PHP 7.1... I am installing it via PECL.
There is a bug report about it: https://github.com/jedisct1/libsodium-php/issues/156
You can overcome this issue by forcing to use 2.0.8
until the issue gets fixed: pecl install -f libsodium-2.0.8
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install libsodium-php
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page