phpseclib

MD5 with RSA in php

时光毁灭记忆、已成空白 提交于 2019-12-31 05:30:26
问题 I'm trying to implement digital signature in php as in java sample code below: Signature rsaSig = Signature.getInstance("MD5withRSA"); RSAPrivateKey clientPrivateKey = readPrivateKeyFromFile(fileName); rsaSig.initSign(clientPrivateKey); String source = msg; byte temp[] = source.getBytes(); rsaSig.update(temp); byte sig[] = rsaSig.sign(); BASE64Encoder encoder = new BASE64Encoder(); return encoder.encode(sig); My php code : $rsa = new Crypt_RSA(); $rsa->loadKey('...'); // in xml format

MD5 with RSA in php

别来无恙 提交于 2019-12-31 05:30:01
问题 I'm trying to implement digital signature in php as in java sample code below: Signature rsaSig = Signature.getInstance("MD5withRSA"); RSAPrivateKey clientPrivateKey = readPrivateKeyFromFile(fileName); rsaSig.initSign(clientPrivateKey); String source = msg; byte temp[] = source.getBytes(); rsaSig.update(temp); byte sig[] = rsaSig.sign(); BASE64Encoder encoder = new BASE64Encoder(); return encoder.encode(sig); My php code : $rsa = new Crypt_RSA(); $rsa->loadKey('...'); // in xml format

phpseclib doesn't upload correct file contents

半城伤御伤魂 提交于 2019-12-30 11:29:26
问题 So what it does is successfully connects then uploads the file logo.png but the contents of the file isn't what was on web host or uploaded with html if i use a html upload code. What it puts in the file is the ACTUAL text between the second ' 's so for that very example the contents of logo.png is literally logo.png and not the picture. require_once("ftp/vendor/autoload.php"); use phpseclib\Net\SFTP; $sftp = new SFTP('SERVER'); if (!$sftp->login('USER', 'PW')) { throw new Exception('Login

Securing webservices of PHP

五迷三道 提交于 2019-12-30 05:18:26
问题 I'm developing a small project in android which is using php webservices' call. I want my webservices to be protected, however by using GET/POST request methods I don't think its much protected. After googling I got RSA implementation in "phpseclib", Its having good documentation as well. But I'm confused so much, so thought post this here. Basically what I need is: from Android I'l call a url with "encrypted parameters merged in one string". (I'l first encode parameters in json and then I'l

Transfering file for download through SFTP with PHP very slow

无人久伴 提交于 2019-12-25 01:49:55
问题 I want to be able to get a file through SFTP from a server in order for my web server to allow users to download it afterwards. To achieve this, I am using the phpseclib library. Unfortunately, this is really slow as I can only achieve speeds of 300-350kb/s when I could achieve over 1mb/s before when directly downloading from the server hosting the original files. For some internal reasons in our company, we have to relocate these files on an other server which only has the port 22 opened, so

RSA Encryption: Create a cipher text in PHP and decrypt it in Javascript

梦想与她 提交于 2019-12-24 11:44:28
问题 I'm having trouble to decrypt a cipher text in client side/javascript which is encrypted in server side/PHP. For encryption in PHP, I'm using the phpseclib and here is my sample code block: define('PUK', 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwMKuLMVuo7vHDwFCbpgxx+RNf xSVC2GRWq9rW0fl4snnhRdrpprPRUO1RMV0wA/ao+fvzi1Sl0lcws3srpe28iLAj Wh5vFM/pFstwzjoHBv/6n4rQouIVy2NT18aFrxlQUCs4DHy5eOo21MjQXrgHwCeP HEc7OK+VpaQ/yKKX8wIDAQAB'); include ('Crypt/RSA.php'); $rsa = new Crypt_RSA(); $plaintext = 'My

Phpseclib connect MYSQL server

一笑奈何 提交于 2019-12-24 10:05:58
问题 I want to connect to my remote MySQL server through port forwarding. Unfortunately my hosting provider don't have php_ssh2 installed on the server so I have to work through phpseclib library. So far I am able to do: 1 - Connect to server using Net_SSH2 : $ssh = new Net_SSH2('xx.xxx.xx.xx'); if (!$ssh->login('user', 'password')) { exit('Login Failed'); } If I do echo $ssh->exec('ls -la'); , it fetches directory listing telling we are connected successfully. if I run 2 - echo $ssh->exec('echo

phpseclib not works with php5-cli from terminal

左心房为你撑大大i 提交于 2019-12-24 08:38:38
问题 I installed php5-cli package on my raspbian (debian OS) and I downloaded phpseclib in /cli/ directory. I created a test file to encrypt text with a public key (generated within my apache server on which I have the same library) in this way: include('libs/Crypt/RSA.php'); $rsa = new Crypt_RSA(); $rsa->loadKey($myPublicKey); $encrypted = $rsa->encrypt("my text"); echo "result: " .$encrypted; If I try to type php test.php the result variable is empty. Why? It's due to the fact I execute the file

phpseclib vs libssh2

橙三吉。 提交于 2019-12-24 05:00:42
问题 In one of my projects am going to connect with alot of servers remotely through SSH using PHP. There are two solutions for it, phpseclib and the ssh2 PECL Extension for PHP which is based on the libssh2 library. So can anyone please compare both and mention their pros and cons etc? 回答1: phpseclib has pretty much zero server requirements. So long as the server supports PHP it'll work. libssh2, in contrast, has to be installed on the server for it to work and a lot of servers don't have it

File encryption in C# with AES, decryption with phpseclib

牧云@^-^@ 提交于 2019-12-24 03:29:06
问题 I am working on a project for secure file transfer which encrypts files using c# client on the customer side. i need to decrypt the files on server side using php and maybe phpseclib. The code here i copied from a msdn example. But i cant work out the decrypt function in php. public static byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes) { byte[] encryptedBytes = null; byte[] saltBytes = passwordBytes; using (MemoryStream ms = new MemoryStream()) { using (RijndaelManaged