phpseclib

Get last 15 lines from a large file in SFTP with phpseclib [duplicate]

你说的曾经没有我的故事 提交于 2019-12-23 00:51:11
问题 This question already has answers here : How do you get last some lines of file via SFTP in PHP (3 answers) Closed 11 months ago . I want to get the last 15 lines from a large file (30MB) from a SFTP server using PHP. I tried using the phpseclib's SFTP functionality like that: include('./Net/SFTP.php'); $sftp = new Net_SFTP("server", 2022); if (!$sftp->login('username', 'password')) { exit("Login error"); } $size = $sftp->size('./file.txt'); $Container = nl2br($sftp->get('./file.txt', false,

Get last 15 lines from a large file in SFTP with phpseclib [duplicate]

天大地大妈咪最大 提交于 2019-12-23 00:51:08
问题 This question already has answers here : How do you get last some lines of file via SFTP in PHP (3 answers) Closed 11 months ago . I want to get the last 15 lines from a large file (30MB) from a SFTP server using PHP. I tried using the phpseclib's SFTP functionality like that: include('./Net/SFTP.php'); $sftp = new Net_SFTP("server", 2022); if (!$sftp->login('username', 'password')) { exit("Login error"); } $size = $sftp->size('./file.txt'); $Container = nl2br($sftp->get('./file.txt', false,

phpseclib/jsbn: encrypt with public key in PHP, decrypt with private key in jsbn

孤街醉人 提交于 2019-12-21 20:55:07
问题 I can successfully generate a public/private keypair using jsbn on the client side. Encrypting and decrypting client side with these keys is fine. I can also transmit that public key to the server and store it in MySQL via PHP. I cannot encrypt something in PHP using the jsbn public key, and then decrypt it client side using the jsbn private key. // attempting to encrypt in PHP using the jsbn public key. // (this public key came from jsbn client side) $jsbn_public_key =

RSA encryption in Java, decryption in PHP

大兔子大兔子 提交于 2019-12-20 15:28:43
问题 I am trying to encrypt an AES key with an RSA public key in and Android app and then decrypt the AES key on a server using PHP with phpseclib. I have tested to make sure that the RSA encryption/decryption work on both platforms by encrypting a static text and decrypting it afterwards to check if I still get the original text. According to the test, the RSA code works individually on each platform but there seems to be a difference between the platforms. In Java, I am using the Bouncy Castle

How to load phpseclib in codeigniter

Deadly 提交于 2019-12-20 04:23:05
问题 As per title, has anyone achieved this? What are the best practices on including this library into codeigniter (v2.1.2) ? I know it can be done by simply using include/require statements like any other PHP application, however as this project will be handed over to multiple devs once complete, I want to ensure it's built correctly using the design patterns the CI dev intended. I've tried the following in a test controller public function index(){ $this->load->library('phpseclib0.3.0/Net/SFTP'

How do I copy or move remote files with phpseclib?

允我心安 提交于 2019-12-19 04:45:13
问题 I've just discovered phpseclib for myself and would like to use it for my bit of code. Somehow I can't find out how I could copy files from one sftp directory into an other sftp directory. Would be great if you could help me out with this. e.g.: copy all files of /jn/xml/ to /jn/xml/backup/ 回答1: $dir = "/jn/xml/"; $files = $sftp->nlist($dir, true); foreach($files as $file) { if ($file == '.' || $file == '..') continue; $sftp->put($dir."backup".'/'.$file, $sftp->get($dir.'/'.$file); } This

How to download a file from an SFTP server using PHP

隐身守侯 提交于 2019-12-18 04:23:18
问题 I'm looking to allow a user to download a file directly from an sftp server, but in the browser. I've found methods to read the file and echo the string (connections using ssh2.sftp or phpseclib) but I need to download, rather than read. Also, I've seen solutions that suggest downloading from the sftp server to the web server, then use readfile() from the web server to the user's local disk. But this means two file transfers, and if the file is large I imagine this would be slow. Can you

Key format need to use in Crypt RSA

自作多情 提交于 2019-12-13 20:29:14
问题 I used this Java function to create Key pairs. KeyPairGenerator keyGen = KeyPairGenerator.getInstance(keyAlgorithm); keyGen.initialize(numBits); KeyPair keyPair = keyGen.genKeyPair(); PrivateKey privateKey = keyPair.getPrivate(); PublicKey publicKey = keyPair.getPublic(); // Get the bytes of the public and private keys byte[] privateKeyBytes = privateKey.getEncoded(); byte[] publicKeyBytes = publicKey.getEncoded(); I got this as public key(similar to this.Not possible to paste here): 0��0 *�H

Server fails when downloading large files with PHP

馋奶兔 提交于 2019-12-13 07:05:41
问题 I'm using the SFTP functions of PHPSecLib to download files from an FTP server. The line $sftp->get($fname); works if the file is up to 200MB, but if it's 300MB, the browser responds with "Firefox can't find the file at [download.php]". That is, it says it can't find the php file I use for downloading the remote file. At first I thought this was due to the memory_limit setting in php.ini, but it doesn't matter if it's set to 128M or 350M; 200MB files still work, and 300MB files fail. And it

Converting RSA Encryption from Javascript to PHP

我与影子孤独终老i 提交于 2019-12-13 07:05:05
问题 I am trying to login to a website (Steam) which encrypts the plaintext password using Javascript RSA as to send the ciphertext in the POST request as a parameter. I am having trouble correctly converting the Javascript RSA from Javascript to PHP. When I attempt to send the ciphertext password created with any of my PHP script's to the website, I get an incorrect login indicating that something is incorrect somewhere in my encryption process. When sending an actual request from the browser and