phpseclib | PHP Secure Communications Library | Cryptography library
kandi X-RAY | phpseclib Summary
kandi X-RAY | phpseclib Summary
MIT-licensed pure-PHP implementations of the following:. SSH-2, SFTP, X.509, an arbitrary-precision integer arithmetic library, Ed25519 / Ed449 / Curve25519 / Curve449, ECDSA / ECDH (with support for 66 curves), RSA (PKCS#1 v2.2 compliant), DSA / DH, DES / 3DES / RC4 / Rijndael / AES / Blowfish / Twofish / Salsa20 / ChaCha20, GCM / Poly1305.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Send a key exchange .
- Create an inline crypt function
- Convert an array to an element .
- Append string to string
- Sign a certificate .
- Encode curve parameters .
- Put data to file .
- Sets the hash
- Divide two numbers
- Generate a random string .
phpseclib Key Features
phpseclib Examples and Code Snippets
Community Discussions
Trending Discussions on phpseclib
QUESTION
I use a bash script (deploy.sh) to deploy my application to a shared host. As part of the deployment process, I clone the latest code from bitbucket using the script below:
...ANSWER
Answered 2022-Feb-22 at 21:30Your script probably shouldn't start ssh-agent
; it should make use of an ssh-agent
that's already running. That way, the user is responsible for starting a single agent that can be used by multiple invocations of the script.
The simplest thing you can do, though, is simply add either
QUESTION
I'm trying to do RSA encryption using PHPSecLib, with a manual install (ie not using Composer).
I'm following these manual installation instructions I found here: https://davescripts.com/manual-installation-of-phpseclib
And trying to do this example which I located here: How to Decrypt RSA OAEP with SHA256 using openssl on PHP
My steps I've taken so far:
Visited the GitHub repository here: https://github.com/phpseclib/phpseclib/tree/3.0
Under 'Code' selected 'Download ZIP'.
Unzipped the files locally and uploaded the entire 'phpseclib' directory to the server.
Created a test script, and troubleshooted multiple layers of includes and use that were needed to get it working.
However, at the moment, I'm getting a new error - "Class name must be a valid object or a string" which I don't understand and can't seem to resolve.
My test script is now as follows:
...ANSWER
Answered 2021-Dec-17 at 05:15You're trying to install phpseclib v3 using the instructions for phpseclib v2. There are two options:
Option 1: Use PHPSecLib V3 With Composer
This option requires SSH access on the server.
To install phpseclib v3 you're gonna need Composer. Once you have that installed you can do composer init
and then composer require phpseclib/phpseclib:~3.0
.
By doing that you can replace this:
QUESTION
I'm trying to decrypt a string using phpseclib.
My hashed string is being generated from a javascript library called jsencrypt. The result of the encryption is saved in a database.
Afterwards I'm using phpseclib3 to try and decrypt the string using this:
...ANSWER
Answered 2021-Dec-08 at 04:49You need to use PKCS1 padding. eg.
QUESTION
I am trying to verify the authenticity of a message across PHP (phpseclib) and C#.
However, there seem to be some issues with the verification on the C# side.
What I have tried :
- Provide the public key to C# but make C# compute the hash and the signature then verify (Output: True)
- Change the hash to the one computed in PHP but make C# compute the signature then verify (Output: True)
- Make C# use PHP's computed hash and signature then verify (Output: False)
PHP Code :
...ANSWER
Answered 2021-Nov-20 at 14:41There are issues in both codes:
By default phpseclib uses PSS as padding (here and in the following v3 assumed). Padding is explicitly set to PKCS#1 v1.5 though, but it is not used because the return value is not applied. For the padding change to take effect, the return value must be considered.
By the way, SHA256 is the default here. AndRSA::ENCRYPTION_PKCS1
is ignored in the context of signing/verifying and can be removed as well.phpseclib hashes the data implicitly when signing. Since in the current phpseclib code the hash is additionally generated explicitly, double hashing is done. This double hashing is not necessary and can be removed.
The double Base64 encoding at the end is also unnecessary and can be removed as well.
Overall:
QUESTION
I'm trying to follow the 3rd party documentation for verifying a webhook body using the Signature
header -- the 3rd party will be referred to as 3P going forward).
3P offered a sample Kotlin implementation using a java library. I am using PHP and decided to try gree/jose as my library.
As a sanity check, I've copied their sample data into my implementation, but I am still getting a false outcome.
...ANSWER
Answered 2021-Oct-26 at 09:02RS256
in Java means RSASSA-PKCS1-v1_5 using SHA-256
QUESTION
Is anyone knows a way to do PKCS 1.5 RSA encryption using a public key in PHP 7 ?. Every PHP library that I tried to that, looks like replaced that encryption padding with OAEP padding because PKCS 1.5 encryption is not secure anymore. (Phpseclib equivalent to Java RSA Encryption) . Given below is PHP code I tried so far. What I am doing wrong here ?. Is there any way to accomplish this task in PHP?. I am using CodeIgniter 3 PHP framework.
...ANSWER
Answered 2021-Aug-07 at 13:49The posted Python (PyCryptodome) and JavaScript (JSEncrypt) reference codes do the following:
- Generation of a timestamp (number of milliseconds elapsed since January 1, 1970 00:00:00 UTC).
- Concatenation of timestamp and token in the format
+
. - Encryption with RSA and PKCS#1 v1.5 padding (RSAES-PKCS1-v1_5)
- Base64 encoding and subsequent URL encoding
The posted PHP code uses different libraries for encryption: phpseclib (V3 and V1) and OpenSSL. The only difference from the reference code turned out to be that the timestamp is determined in seconds (instead of milliseconds), which was eventually identified as the cause of the problem.
The rest is consistent with the reference code, including the encryption with RSA and PKCS#1 v1.5 padding originally suspected as the cause of the bug, as could be easily verified by using a valid key pair and decrypting the ciphertext generated with the PHP code with a second independent application (e.g. online).
Note that phpseclib V3 specifies PKCS#1 v1.5 padding in the context of encryption with RSA::ENCRYPTION_PKCS1
.
QUESTION
I'm using a key pair generated by phpseclib and then I use it to encrypt in C# a message and decrypt in PHP.
The public key is:
...ANSWER
Answered 2021-Jul-24 at 14:49QUESTION
I am using the below script: -
...ANSWER
Answered 2021-Jun-02 at 17:24The error message seems fairly straight-forward to me: the key size you used isn't supported by that library. In fact, you appear to have only pasted part of the message, which goes on to list the key sizes which are supported: https://github.com/phpseclib/phpseclib/blob/7e38313802b62606cf27ddf573a7c47e88b5d33f/phpseclib/Crypt/AES.php#L118
'Key of size ' . strlen($key) . ' not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported'
So your problem is not understanding what the PHP can do, but understanding what the JS is doing with your input.
The clue to that is in the CryptoJS docs:
CryptoJS supports AES-128, AES-192, and AES-256. It will pick the variant by the size of the key you pass in. If you use a passphrase, then it will generate a 256-bit key.
So the library agrees that there are three valid key lengths, but supports passing in a "passphrase" instead which will be used to generate a key. The exact algorithm it uses to do that isn't documented; presumably it uses some Key Derivation Function with fixed parameters, so that the same passphrase will always produce the same key. If you really need to emulate it, you'll need to trace through the source code.
If you just need code that's compatible with both libraries, generate a random key of one of the supported lengths, and use that in both places.
QUESTION
I have retrieved an array like this:
echo "
ANSWER
Answered 2021-May-26 at 08:53The BigInteger
class
has a toHex()
method. So you can get the hex value like this:
QUESTION
I just installed docker desktop on my windows box, but I uses the new output style, i'd like to switch back to the old style, having trouble finding the exact command or profile part to change.
What I have
...ANSWER
Answered 2021-Mar-04 at 20:55The new logging style comes from the BuildKit features.
You can disable this in the Docker Desktop GUI:
- select the Docker Engine tab
- set
"features"{ "buildkit" : false }
Then if you want to use the logging features again, you can run with DOCKER_BUILDKIT=1
. I believe you can run with DOCKER_BUILDKIT=0
if you want to selectively disable but haven't tested that yet.
Of course, be aware that you'll lose out on the following features that BuildKit adds to Docker:
- Docker images created with BuildKit can be pushed to Docker Hub just like Docker images created with legacy build
- the Dockerfile format that works on legacy build will also work with BuildKit builds
- The new --secret command line option allows the user to pass secret information for building new images with a specified Dockerfile
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install phpseclib
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
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