├── x509 ├── crl.bin ├── spkac.txt ├── csr.txt ├── phpseclib.txt ├── selfsigned.txt ├── google.txt ├── signer.txt ├── googleca.txt ├── google2.txt ├── oidparse.phps ├── asn1tutorial.html ├── intro.html ├── 2.0 │ └── dnprops.html ├── dnprops.html └── decoder.php ├── images ├── file.gif ├── minus.gif ├── plus.gif ├── folder.gif ├── github.png ├── pear-icon.png ├── ajax-loader.gif ├── folder-closed.gif ├── treeview-gray.gif ├── treeview-new.gif ├── treeview-red.gif ├── request-a-demo.png ├── treeview-black.gif ├── orange-learnmore.png ├── treeview-default.gif ├── treeview-famfamfam.gif ├── treeview-gray-line.gif ├── treeview-red-line.gif ├── treeview-black-line.gif ├── treeview-default-line.gif ├── treeview-famfamfam-line.gif ├── ui-icons_222222_256x240.png ├── ui-icons_228ef1_256x240.png ├── ui-icons_ef8c08_256x240.png ├── ui-icons_ffd27a_256x240.png ├── ui-icons_ffffff_256x240.png ├── ui-bg_flat_10_000000_40x100.png ├── ui-bg_glass_100_f6f6f6_1x400.png ├── ui-bg_glass_100_fdf5ce_1x400.png ├── ui-bg_glass_65_ffffff_1x400.png ├── button │ ├── ui-icons_222222_256x240.png │ ├── ui-icons_4b8e0b_256x240.png │ ├── ui-icons_a83300_256x240.png │ ├── ui-icons_cccccc_256x240.png │ ├── ui-icons_ffffff_256x240.png │ ├── ui-bg_flat_30_cccccc_40x100.png │ ├── ui-bg_flat_50_5c5c5c_40x100.png │ ├── ui-bg_glass_20_555555_1x400.png │ ├── ui-bg_glass_40_0078a3_1x400.png │ ├── ui-bg_glass_40_ffc73d_1x400.png │ ├── ui-bg_inset-soft_25_000000_1x100.png │ ├── ui-bg_inset-soft_30_f58400_1x100.png │ ├── ui-bg_gloss-wave_25_333333_500x100.png │ └── ui-bg_highlight-soft_80_eeeeee_1x100.png ├── ui-bg_gloss-wave_35_f6a828_500x100.png ├── ui-bg_diagonals-thick_18_b81900_40x40.png ├── ui-bg_diagonals-thick_20_666666_40x40.png ├── ui-bg_highlight-soft_100_eeeeee_1x100.png └── ui-bg_highlight-soft_75_ffe45c_1x100.png ├── css ├── ui-lightness │ └── images │ │ ├── ui-icons_222222_256x240.png │ │ ├── ui-icons_228ef1_256x240.png │ │ ├── ui-icons_ef8c08_256x240.png │ │ ├── ui-icons_ffd27a_256x240.png │ │ ├── ui-icons_ffffff_256x240.png │ │ ├── ui-bg_flat_10_000000_40x100.png │ │ ├── ui-bg_glass_100_f6f6f6_1x400.png │ │ ├── ui-bg_glass_100_fdf5ce_1x400.png │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ ├── ui-bg_gloss-wave_35_f6a828_500x100.png │ │ ├── ui-bg_highlight-soft_75_ffe45c_1x100.png │ │ ├── ui-bg_diagonals-thick_18_b81900_40x40.png │ │ ├── ui-bg_diagonals-thick_20_666666_40x40.png │ │ └── ui-bg_highlight-soft_100_eeeeee_1x100.png ├── text.css ├── prettify.css ├── jquery.treeview.css ├── reset.css └── 960.css ├── README.md ├── crypt ├── phpaes.phps ├── movable-type.phps ├── phpclasses2.phps ├── phpseclib-rijndael.phps ├── phpseclib.phps ├── phpseclib-aes.phps ├── phpclasses1.phps ├── benchmark.phps └── cfb-demo.phps ├── ssh ├── download.phps ├── upload.phps ├── intro.html ├── keys.html ├── pty.html ├── auth.html ├── 2.0 │ └── auth.html └── compare.html ├── math ├── benchmark.phps ├── col3.phps ├── col4.phps ├── col5.phps ├── col1.phps ├── col2.phps ├── speed.phps └── intro.html ├── js ├── common.js ├── jquery.cookie.js └── jquery.treeview.js ├── 2.0.html ├── sftp ├── intro.html ├── log.txt └── 2.0 │ └── examples.html ├── rsa └── intro.html └── index.html /x509/crl.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/x509/crl.bin -------------------------------------------------------------------------------- /images/file.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/file.gif -------------------------------------------------------------------------------- /images/minus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/minus.gif -------------------------------------------------------------------------------- /images/plus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/plus.gif -------------------------------------------------------------------------------- /images/folder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/folder.gif -------------------------------------------------------------------------------- /images/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/github.png -------------------------------------------------------------------------------- /images/pear-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/pear-icon.png -------------------------------------------------------------------------------- /images/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ajax-loader.gif -------------------------------------------------------------------------------- /images/folder-closed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/folder-closed.gif -------------------------------------------------------------------------------- /images/treeview-gray.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-gray.gif -------------------------------------------------------------------------------- /images/treeview-new.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-new.gif -------------------------------------------------------------------------------- /images/treeview-red.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-red.gif -------------------------------------------------------------------------------- /images/request-a-demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/request-a-demo.png -------------------------------------------------------------------------------- /images/treeview-black.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-black.gif -------------------------------------------------------------------------------- /images/orange-learnmore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/orange-learnmore.png -------------------------------------------------------------------------------- /images/treeview-default.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-default.gif -------------------------------------------------------------------------------- /images/treeview-famfamfam.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-famfamfam.gif -------------------------------------------------------------------------------- /images/treeview-gray-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-gray-line.gif -------------------------------------------------------------------------------- /images/treeview-red-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-red-line.gif -------------------------------------------------------------------------------- /images/treeview-black-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-black-line.gif -------------------------------------------------------------------------------- /images/treeview-default-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-default-line.gif -------------------------------------------------------------------------------- /images/treeview-famfamfam-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/treeview-famfamfam-line.gif -------------------------------------------------------------------------------- /images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /images/ui-icons_228ef1_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-icons_228ef1_256x240.png -------------------------------------------------------------------------------- /images/ui-icons_ef8c08_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-icons_ef8c08_256x240.png -------------------------------------------------------------------------------- /images/ui-icons_ffd27a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-icons_ffd27a_256x240.png -------------------------------------------------------------------------------- /images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /images/ui-bg_flat_10_000000_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_flat_10_000000_40x100.png -------------------------------------------------------------------------------- /images/ui-bg_glass_100_f6f6f6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_glass_100_f6f6f6_1x400.png -------------------------------------------------------------------------------- /images/ui-bg_glass_100_fdf5ce_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_glass_100_fdf5ce_1x400.png -------------------------------------------------------------------------------- /images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /images/button/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /images/button/ui-icons_4b8e0b_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-icons_4b8e0b_256x240.png -------------------------------------------------------------------------------- /images/button/ui-icons_a83300_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-icons_a83300_256x240.png -------------------------------------------------------------------------------- /images/button/ui-icons_cccccc_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-icons_cccccc_256x240.png -------------------------------------------------------------------------------- /images/button/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /images/button/ui-bg_flat_30_cccccc_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_flat_30_cccccc_40x100.png -------------------------------------------------------------------------------- /images/button/ui-bg_flat_50_5c5c5c_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_flat_50_5c5c5c_40x100.png -------------------------------------------------------------------------------- /images/button/ui-bg_glass_20_555555_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_glass_20_555555_1x400.png -------------------------------------------------------------------------------- /images/button/ui-bg_glass_40_0078a3_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_glass_40_0078a3_1x400.png -------------------------------------------------------------------------------- /images/button/ui-bg_glass_40_ffc73d_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_glass_40_ffc73d_1x400.png -------------------------------------------------------------------------------- /images/ui-bg_gloss-wave_35_f6a828_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_gloss-wave_35_f6a828_500x100.png -------------------------------------------------------------------------------- /images/ui-bg_diagonals-thick_18_b81900_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_diagonals-thick_18_b81900_40x40.png -------------------------------------------------------------------------------- /images/ui-bg_diagonals-thick_20_666666_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_diagonals-thick_20_666666_40x40.png -------------------------------------------------------------------------------- /images/ui-bg_highlight-soft_100_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_highlight-soft_100_eeeeee_1x100.png -------------------------------------------------------------------------------- /images/ui-bg_highlight-soft_75_ffe45c_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/ui-bg_highlight-soft_75_ffe45c_1x100.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-icons_228ef1_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-icons_228ef1_256x240.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-icons_ef8c08_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-icons_ef8c08_256x240.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-icons_ffd27a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-icons_ffd27a_256x240.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /images/button/ui-bg_inset-soft_25_000000_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_inset-soft_25_000000_1x100.png -------------------------------------------------------------------------------- /images/button/ui-bg_inset-soft_30_f58400_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_inset-soft_30_f58400_1x100.png -------------------------------------------------------------------------------- /images/button/ui-bg_gloss-wave_25_333333_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_gloss-wave_25_333333_500x100.png -------------------------------------------------------------------------------- /images/button/ui-bg_highlight-soft_80_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/images/button/ui-bg_highlight-soft_80_eeeeee_1x100.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png -------------------------------------------------------------------------------- /css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phpseclib/docs/HEAD/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | phpseclib documentation makes use of the following: 2 | 3 | * http://960.gs/ 4 | * http://code.google.com/p/google-code-prettify/ 5 | * http://jquery.com/ 6 | * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ 7 | * http://jqueryui.com/ -------------------------------------------------------------------------------- /x509/spkac.txt: -------------------------------------------------------------------------------- 1 | MIIBQzCBrTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAjNNAQRK+IkRbovEEQC5E2f8iY021bHpsnpHyGJSLJqqJaYJIVzZF79kTUpDPMlhku/uOWBKNlW91/fP9s/vI+G9uHHgeYNGegf0V3OhKbx519RmDGKH7H4z9lN4rPKmFr7sz75nO8Q/kDm+sBeafRV0jho15p7pY4z2ni8ABdwMCAwEAARYJMTIzNDU2Nzg5MA0GCSqGSIb3DQEBBAUAA4GBAIfIg6pR1bSrC7FZISLMeZnvvg7xPOOiCPRAaarxs+h9rPzesrtJT8hDhI7MdOpWefoV2tD8JSAn+tQARecqb5556B9v0sIdUYLJSZ3YIt6e3sJJvNlTSvnPgQ0st4AhgOz7DcWTghRbFQUo8uTamYdk8NOw7w88STSmWp4pJi30 -------------------------------------------------------------------------------- /crypt/phpaes.phps: -------------------------------------------------------------------------------- 1 | encrypt($plaintext); 18 | 19 | $elapsed = microtime(true) - $start; 20 | echo "Elapsed time: $elapsed"; -------------------------------------------------------------------------------- /crypt/movable-type.phps: -------------------------------------------------------------------------------- 1 | encrypt($plaintext, 'abcdefghijklmnop'); 18 | 19 | $elapsed = microtime(true) - $start; 20 | echo "Elapsed time: $elapsed"; -------------------------------------------------------------------------------- /crypt/phpseclib-rijndael.phps: -------------------------------------------------------------------------------- 1 | setKey('abcdefghijklmnop'); 18 | $aes->encrypt($plaintext); 19 | 20 | $elapsed = microtime(true) - $start; 21 | echo "Elapsed time: $elapsed"; -------------------------------------------------------------------------------- /crypt/phpseclib.phps: -------------------------------------------------------------------------------- 1 | setKey('abcdefghijklmnop'); 19 | $aes->encrypt($plaintext); 20 | 21 | $elapsed = microtime(true) - $start; 22 | echo "Elapsed time: $elapsed"; -------------------------------------------------------------------------------- /crypt/phpseclib-aes.phps: -------------------------------------------------------------------------------- 1 | setKey('abcdefghijklmnop'); 19 | $aes->encrypt($plaintext); 20 | 21 | $elapsed = microtime(true) - $start; 22 | echo "Elapsed time: $elapsed"; -------------------------------------------------------------------------------- /x509/csr.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIBVjCBwgIAMB4xHDAaBgNVBAoME3BocHNlY2xpYiBkZW1vIGNlcnQwgZ0wCwYJKoZIhvcNAQEB 3 | A4GNADCBiQKBgQClAGXDCg5G9JmpSakvmmgAMtaxEHHnm0uzdirxl9uRKjycd61s+c66Qg/82XGf 4 | ef8wY6+xdBr00uKwtDpSbIvIlddVbwWfqkJAimfKCM1uhyCzq6PjtQRcPAzCV8so9nzQzuGYymFl 5 | nhRv8gF7RLko3vtjFi8UoYp8w1cplbHX/wIDAQABMAsGCSqGSIb3DQEBBQOBgQAhFc1zN5trm9nL 6 | vgB0NsiarO98bB/wT8VvktmF6b80zg8qRuaTvIWiucEfJzZlrNqbog689M3G60ayeGYsGxTKUa+x 7 | PQGokjE3dvdaozqQAasS6JyeqdKto9cut915Wr7kwIut1JrBbM3NuwRYWl9OF4GEk/9vgw8ivNen 8 | zQXIqA== 9 | -----END CERTIFICATE REQUEST----- -------------------------------------------------------------------------------- /crypt/phpclasses1.phps: -------------------------------------------------------------------------------- 1 | makeKey('abcdefghijklmnop'); 18 | for ($i = 0; $i < 1024*1024; $i+=16) { 19 | $aes->blockEncrypt(substr($plaintext, $i, 16), $key); 20 | } 21 | 22 | $elapsed = microtime(true) - $start; 23 | echo "Elapsed time: $elapsed"; -------------------------------------------------------------------------------- /x509/phpseclib.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBrTCCARigAwIBAgIAMAsGCSqGSIb3DQEBBTAeMRwwGgYDVQQKDBNwaHBzZWNsaWIgZGVtbyBj 3 | ZXJ0MCIYDzIwMTIwODA3MDQwODEzWhgPMjAxMzA4MDcwNDA4MTNaMB4xHDAaBgNVBAoME3BocHNl 4 | Y2xpYiBkZW1vIGNlcnQwgZ0wCwYJKoZIhvcNAQEBA4GNADCBiQKBgQDZKEFjSwOisnROUe/aURxl 5 | quXhhUx/3joyyQ/GC5k3rUEcYNEebKcOI/UlkQVChkFyOuli8XLtTTiNaYTKH1AeHW0rQzVnqSSJ 6 | hv4SdasXadeLviz/Yv5v7UjwNjOZasQcpAUrjxL8GkxPW2/gFj6UjPxAjuDkxImt3YWpesTf1QID 7 | AQABMAsGCSqGSIb3DQEBBQOBgQCMkXteWuridCtR+LzYAoQKiU7GtZCYxonC4EB1Lkst16kBWORn 8 | JISn1GtVnv11R6XlBew9YnoVJBb0TO3oAzlRYEOv818oKJzP0+AIKipHxxwCa+9F3TokMBH8eWGT 9 | J+wi04luD/k4UphTcLnM4NIDErBF0X6M0Ot1x6IyR4AH4Q== 10 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /crypt/benchmark.phps: -------------------------------------------------------------------------------- 1 | $result) { 22 | echo ' 23 | ' . $key . ' 24 | ' . $result . ' 25 | '; 26 | echo "\r\n"; 27 | } -------------------------------------------------------------------------------- /x509/selfsigned.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICPDCCAaUCEHC65B0Q2Sk0tjjKewPMur8wDQYJKoZIhvcNAQECBQAwXzELMAkG 3 | A1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFz 4 | cyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTk2 5 | MDEyOTAwMDAwMFoXDTI4MDgwMTIzNTk1OVowXzELMAkGA1UEBhMCVVMxFzAVBgNV 6 | BAoTDlZlcmlTaWduLCBJbmMuMTcwNQYDVQQLEy5DbGFzcyAzIFB1YmxpYyBQcmlt 7 | YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GN 8 | ADCBiQKBgQDJXFme8huKARS0EN8EQNvjV69qRUCPhAwL0TPZ2RHP7gJYHyX3KqhE 9 | BarsAx94f56TuZoAqiN91qyFomNFx3InzPRMxnVx0jnvT0Lwdd8KkMaOIG+YD/is 10 | I19wKTakyYbnsZogy1Olhec9vn2a/iRFM9x2Fe0PonFkTGUugWhFpwIDAQABMA0G 11 | CSqGSIb3DQEBAgUAA4GBALtMEivPLCYATxQT3ab7/AoRhIzzKBxnki98tsX63/Do 12 | lbwdj2wsqFHMc9ikwFPwTtYmwHYBV4GSXiHx0bH/59AhWM1pF+NEHJwZRDmJXNyc 13 | AA9WjQKZ7aKQRUzkuxCkPfAyAw7xzvjoyVGM5mKf5p/AfbdynMk2OmufTqj/ZA1k 14 | -----END CERTIFICATE----- 15 | -------------------------------------------------------------------------------- /x509/google.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDITCCAoqgAwIBAgIQT52W2WawmStUwpV8tBV9TTANBgkqhkiG9w0BAQUFADBM 3 | MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg 4 | THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0xMTEwMjYwMDAwMDBaFw0x 5 | MzA5MzAyMzU5NTlaMGgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh 6 | MRYwFAYDVQQHFA1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKFApHb29nbGUgSW5jMRcw 7 | FQYDVQQDFA53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC 8 | gYEA3rcmQ6aZhc04pxUJuc8PycNVjIjujI0oJyRLKl6g2Bb6YRhLz21ggNM1QDJy 9 | wI8S2OVOj7my9tkVXlqGMaO6hqpryNlxjMzNJxMenUJdOPanrO/6YvMYgdQkRn8B 10 | d3zGKokUmbuYOR2oGfs5AER9G5RqeC1prcB6LPrQ2iASmNMCAwEAAaOB5zCB5DAM 11 | BgNVHRMBAf8EAjAAMDYGA1UdHwQvMC0wK6ApoCeGJWh0dHA6Ly9jcmwudGhhd3Rl 12 | LmNvbS9UaGF3dGVTR0NDQS5jcmwwKAYDVR0lBCEwHwYIKwYBBQUHAwEGCCsGAQUF 13 | BwMCBglghkgBhvhCBAEwcgYIKwYBBQUHAQEEZjBkMCIGCCsGAQUFBzABhhZodHRw 14 | Oi8vb2NzcC50aGF3dGUuY29tMD4GCCsGAQUFBzAChjJodHRwOi8vd3d3LnRoYXd0 15 | ZS5jb20vcmVwb3NpdG9yeS9UaGF3dGVfU0dDX0NBLmNydDANBgkqhkiG9w0BAQUF 16 | AAOBgQAhrNWuyjSJWsKrUtKyNGadeqvu5nzVfsJcKLt0AMkQH0IT/GmKHiSgAgDp 17 | ulvKGQSy068Bsn5fFNum21K5mvMSf3yinDtvmX3qUA12IxL/92ZzKbeVCq3Yi7Le 18 | IOkKcGQRCMha8X2e7GmlpdWC1ycenlbN0nbVeSv3JUMcafC4+Q== 19 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /x509/signer.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDIzCCAoygAwIBAgIEMAAAAjANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJV 3 | UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNzA1BgNVBAsTLkNsYXNzIDMgUHVi 4 | bGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNTEzMDAw 5 | MDAwWhcNMTQwNTEyMjM1OTU5WjBMMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhh 6 | d3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBD 7 | QTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1NNn0I0Vf67NMf59HZGhPwtx 8 | PKzMyGT7Y/wySweUvW+Aui/hBJPAM/wJMyPpC3QrccQDxtLN4i/1CWPN/0ilAL/g 9 | 5/OIty0y3pg25gqtAHvEZEo7hHUD8nCSfQ5i9SGraTaEMXWQ+L/HbIgbBpV8yeWo 10 | 3nWhLHpo39XKHIdYYBkCAwEAAaOB/jCB+zASBgNVHRMBAf8ECDAGAQH/AgEAMAsG 11 | A1UdDwQEAwIBBjARBglghkgBhvhCAQEEBAMCAQYwKAYDVR0RBCEwH6QdMBsxGTAX 12 | BgNVBAMTEFByaXZhdGVMYWJlbDMtMTUwMQYDVR0fBCowKDAmoCSgIoYgaHR0cDov 13 | L2NybC52ZXJpc2lnbi5jb20vcGNhMy5jcmwwMgYIKwYBBQUHAQEEJjAkMCIGCCsG 14 | AQUFBzABhhZodHRwOi8vb2NzcC50aGF3dGUuY29tMDQGA1UdJQQtMCsGCCsGAQUF 15 | BwMBBggrBgEFBQcDAgYJYIZIAYb4QgQBBgpghkgBhvhFAQgBMA0GCSqGSIb3DQEB 16 | BQUAA4GBAFWsY+reod3SkF+fC852vhNRj5PZBSvIG3dLrWlQoe7e3P3bB+noOZTc 17 | q3J5Lwa/q4FwxKjt6lM07e8eU9kGx1Yr0Vz00YqOtCuxN5BICEIlxT6Ky3/rbwTR 18 | bcV0oveifHtgPHfNDs5IAn8BL7abN+AqKjbc1YXWrOU/VG+WHgWv 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /css/text.css: -------------------------------------------------------------------------------- 1 | /* 2 | 960 Grid System ~ Text CSS. 3 | Learn more ~ http://960.gs/ 4 | 5 | Licensed under GPL and MIT. 6 | */ 7 | 8 | /* `Basic HTML 9 | ----------------------------------------------------------------------------------------------------*/ 10 | 11 | body { 12 | font: 13px/1.5 'Helvetica Neue', Arial, 'Liberation Sans', FreeSans, sans-serif; 13 | } 14 | 15 | pre, 16 | code { 17 | font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace; 18 | } 19 | 20 | hr { 21 | border: 0 #ccc solid; 22 | border-top-width: 1px; 23 | clear: both; 24 | height: 0; 25 | } 26 | 27 | /* `Headings 28 | ----------------------------------------------------------------------------------------------------*/ 29 | 30 | h1 { 31 | font-size: 25px; 32 | } 33 | 34 | h2 { 35 | font-size: 23px; 36 | } 37 | 38 | h3 { 39 | font-size: 21px; 40 | } 41 | 42 | h4 { 43 | font-size: 19px; 44 | } 45 | 46 | h5 { 47 | font-size: 17px; 48 | } 49 | 50 | h6 { 51 | font-size: 15px; 52 | } 53 | 54 | /* `Spacing 55 | ----------------------------------------------------------------------------------------------------*/ 56 | 57 | ol { 58 | list-style: decimal; 59 | } 60 | 61 | ul { 62 | list-style: disc; 63 | } 64 | 65 | li { 66 | margin-left: 30px; 67 | } 68 | 69 | p, 70 | dl, 71 | hr, 72 | h1, 73 | h2, 74 | h3, 75 | h4, 76 | h5, 77 | h6, 78 | ol, 79 | ul, 80 | pre, 81 | table, 82 | address, 83 | fieldset, 84 | figure { 85 | margin-bottom: 20px; 86 | } -------------------------------------------------------------------------------- /x509/googleca.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEBDCCAuygAwIBAgIDAjppMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT 3 | MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i 4 | YWwgQ0EwHhcNMTMwNDA1MTUxNTU1WhcNMTUwNDA0MTUxNTU1WjBJMQswCQYDVQQG 5 | EwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzElMCMGA1UEAxMcR29vZ2xlIEludGVy 6 | bmV0IEF1dGhvcml0eSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB 7 | AJwqBHdc2FCROgajguDYUEi8iT/xGXAaiEZ+4I/F8YnOIe5a/mENtzJEiaB0C1NP 8 | VaTOgmKV7utZX8bhBYASxF6UP7xbSDj0U/ck5vuR6RXEz/RTDfRK/J9U3n2+oGtv 9 | h8DQUB8oMANA2ghzUWx//zo8pzcGjr1LEQTrfSTe5vn8MXH7lNVg8y5Kr0LSy+rE 10 | ahqyzFPdFUuLH8gZYR/Nnag+YyuENWllhMgZxUYi+FOVvuOAShDGKuy6lyARxzmZ 11 | EASg8GF6lSWMTlJ14rbtCMoU/M4iarNOz0YDl5cDfsCx3nuvRTPPuj5xt970JSXC 12 | DTWJnZ37DhF5iR43xa+OcmkCAwEAAaOB+zCB+DAfBgNVHSMEGDAWgBTAephojYn7 13 | qwVkDBF9qn1luMrMTjAdBgNVHQ4EFgQUSt0GFhu89mi1dvWBtrtiGrpagS8wEgYD 14 | VR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAQYwOgYDVR0fBDMwMTAvoC2g 15 | K4YpaHR0cDovL2NybC5nZW90cnVzdC5jb20vY3Jscy9ndGdsb2JhbC5jcmwwPQYI 16 | KwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwOi8vZ3RnbG9iYWwtb2NzcC5n 17 | ZW90cnVzdC5jb20wFwYDVR0gBBAwDjAMBgorBgEEAdZ5AgUBMA0GCSqGSIb3DQEB 18 | BQUAA4IBAQA21waAESetKhSbOHezI6B1WLuxfoNCunLaHtiONgaX4PCVOzf9G0JY 19 | /iLIa704XtE7JW4S615ndkZAkNoUyHgN7ZVm2o6Gb4ChulYylYbc3GrKBIxbf/a/ 20 | zG+FA1jDaFETzf3I93k9mTXwVqO94FntT0QJo544evZG0R0SnU++0ED8Vf4GXjza 21 | HFa9llF7b1cq26KqltyMdMKVvvBulRP/F/A8rLIQjcxz++iPAsbw+zOzlTvjwsto 22 | WHPbqCRiOwY1nQ2pM714A5AuTHhdUDqB1O6gyHA43LL5Z/qHQF1hwFGPa4NrzQU6 23 | yuGnBXj8ytqU0CwIPX4WecigUCAkVDNx 24 | -----END CERTIFICATE----- -------------------------------------------------------------------------------- /ssh/download.phps: -------------------------------------------------------------------------------- 1 | login('username', 'password'); 44 | 45 | $sftp->get('1mb'); 46 | 47 | $elapsed = microtime(true) - $start; 48 | 49 | echo "remotehost / phpseclib took $elapsed seconds\r\n"; 50 | 51 | // -------------------------------------- 52 | 53 | $start = microtime(true); 54 | 55 | $sftp = new Net_SFTP('127.0.0.1'); 56 | $sftp->login('username', 'password'); 57 | 58 | $sftp->get('1mb'); 59 | 60 | $elapsed = microtime(true) - $start; 61 | 62 | echo "localhost / phpseclib took $elapsed seconds\r\n"; -------------------------------------------------------------------------------- /ssh/upload.phps: -------------------------------------------------------------------------------- 1 | login('username', 'password'); 40 | 41 | $sftp->put('1mb', str_repeat('a', 1024 * 1024)); 42 | 43 | $elapsed = microtime(true) - $start; 44 | 45 | echo "remotehost / phpseclib took $elapsed seconds\r\n"; 46 | 47 | // -------------------------------------- 48 | 49 | $start = microtime(true); 50 | 51 | $sftp = new Net_SFTP('127.0.0.1'); 52 | $sftp->login('username', 'password'); 53 | 54 | $sftp->put('1mb', str_repeat('a', 1024 * 1024)); 55 | 56 | $elapsed = microtime(true) - $start; 57 | 58 | echo "localhost / phpseclib took $elapsed seconds\r\n"; -------------------------------------------------------------------------------- /math/benchmark.phps: -------------------------------------------------------------------------------- 1 | $bin) { 9 | for ($i = 1; $i <= 5; $i++) { 10 | switch ($bin) { 11 | case 'php44': 12 | case 'php50': 13 | if ($i >= 5) { 14 | continue 2; 15 | } 16 | } 17 | 18 | echo "$bin col$i.php"; 19 | 20 | $result = substr(shell_exec("$bin col$i.php"), 8); 21 | if ($result[0] != ' ') { 22 | exit("FAILED ON $bin / col$i"); 23 | } 24 | $result = substr($result, 1); 25 | if (!isset($results[$keys[$key]])) { 26 | $results[$keys[$key]] = array(); 27 | } 28 | 29 | $result2 = substr(shell_exec("$bin col$i.php"), 9); 30 | $elapsed = ($result + $result2) / 2; 31 | if ($elapsed > $max) { 32 | $max = $elapsed; 33 | } 34 | $results[$keys[$key]][] = $elapsed; 35 | 36 | echo " = $elapsed\r\n"; 37 | } 38 | } 39 | 40 | echo "\r\n"; 41 | 42 | foreach ($results as $key => $result) { 43 | echo '' . $key . ''; 44 | for ($i = 0; $i < 5; $i++) { 45 | if (!isset($result[$i])) { 46 | echo ''; 47 | continue; 48 | } 49 | $r = intval(($result[$i] / $max) * 255); 50 | $gb = 255 - $r; 51 | $r = str_pad(dechex($r), 2, '0', STR_PAD_RIGHT); 52 | $gb = str_pad(dechex($gb), 2, '0', STR_PAD_RIGHT); 53 | echo '' . number_format($result[$i], 3) . ''; 54 | } 55 | echo ''; 56 | echo "\r\n"; 57 | } -------------------------------------------------------------------------------- /x509/google2.txt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEdjCCA16gAwIBAgIIRi5CVrsRlNwwDQYJKoZIhvcNAQEFBQAwSTELMAkGA1UE 3 | BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxJTAjBgNVBAMTHEdvb2dsZSBJbnRl 4 | cm5ldCBBdXRob3JpdHkgRzIwHhcNMTQwNzMwMTIwNDQwWhcNMTQxMDI4MDAwMDAw 5 | WjBoMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwN 6 | TW91bnRhaW4gVmlldzETMBEGA1UECgwKR29vZ2xlIEluYzEXMBUGA1UEAwwOd3d3 7 | Lmdvb2dsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3iU4C 8 | +boB4HiJ1nD9NhjWAi78lsnZ3q4ugAqhn0sXIMNxuZlrLvwS+hkbYKkq/nboDl2d 9 | RygMvEakzZz0VFA/78/NLhyLETqJvNHxQnrnk7vQ0eB3vJY/8s6ysMmraBlvzhsv 10 | QA3HfWKUp8DVD/EEz5Lug31cSEo7oM52ucAYz5ZUX34nUYIyV4dJRfh7abrJAs5L 11 | N4dGlTxhnbkJ5z/S9eLdAJxcdI7CL8vWZI/mClgF6Yq4zWWrDrB3LXoZrv3CTJo5 12 | M2ksppXntJP4rHqrjl0SKfBxzwisC2xkFwSnR0f6rPuFe2g1n8GpjHd/tes+nJDW 13 | oTt49C1teX/XTwPDAgMBAAGjggFBMIIBPTAdBgNVHSUEFjAUBggrBgEFBQcDAQYI 14 | KwYBBQUHAwIwGQYDVR0RBBIwEIIOd3d3Lmdvb2dsZS5jb20waAYIKwYBBQUHAQEE 15 | XDBaMCsGCCsGAQUFBzAChh9odHRwOi8vcGtpLmdvb2dsZS5jb20vR0lBRzIuY3J0 16 | MCsGCCsGAQUFBzABhh9odHRwOi8vY2xpZW50czEuZ29vZ2xlLmNvbS9vY3NwMB0G 17 | A1UdDgQWBBTkPWzCDBLpfBkgUzZ27yh3N9iISjAMBgNVHRMBAf8EAjAAMB8GA1Ud 18 | IwQYMBaAFErdBhYbvPZotXb1gba7Yhq6WoEvMBcGA1UdIAQQMA4wDAYKKwYBBAHW 19 | eQIFATAwBgNVHR8EKTAnMCWgI6Ahhh9odHRwOi8vcGtpLmdvb2dsZS5jb20vR0lB 20 | RzIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQAtVQG9M/e24GEX5TzPIXA1ZfKat4ZC 21 | p3Hv+kNp8yk4tF8EII2IoQRroKcmYi6GQUPI2sODkkMN++obfUHB4n3UNDikfTbE 22 | oEjeMYvkQqvtX2A3NofQG3/vxD4KrPYgsRpp+yN6qk3DO5e8DrObGr5pArFRglOt 23 | 3aJQNzicJg7ygIvn9wL0emRm1vOzV2TwiMlOCiue5ANgKuIcutP9joc+noF5RaPS 24 | P9KzVXnM4Z6n+IFdFm8+RtU+7SXvORqRK7cVr2TkPhJPmL5If50iKVSlvryNXKOE 25 | xxKMbav/sRFQp9KmLOVluKAqbEyOz8escGXBl5y41Q6r1dNscqU5bnEu 26 | -----END CERTIFICATE----- 27 | -------------------------------------------------------------------------------- /css/prettify.css: -------------------------------------------------------------------------------- 1 | /* Pretty printing styles. Used with prettify.js. */ 2 | 3 | /* SPAN elements with the classes below are added by prettyprint. */ 4 | .pln { color: #000 } /* plain text */ 5 | 6 | @media screen { 7 | .str { color: #080 } /* string content */ 8 | .kwd { color: #008 } /* a keyword */ 9 | .com { color: #800 } /* a comment */ 10 | .typ { color: #606 } /* a type name */ 11 | .lit { color: #066 } /* a literal value */ 12 | /* punctuation, lisp open bracket, lisp close bracket */ 13 | .pun, .opn, .clo { color: #660 } 14 | .tag { color: #008 } /* a markup tag name */ 15 | .atn { color: #606 } /* a markup attribute name */ 16 | .atv { color: #080 } /* a markup attribute value */ 17 | .dec, .var { color: #606 } /* a declaration; a variable name */ 18 | .fun { color: red } /* a function name */ 19 | } 20 | 21 | /* Use higher contrast and text-weight for printable form. */ 22 | @media print, projection { 23 | .str { color: #060 } 24 | .kwd { color: #006; font-weight: bold } 25 | .com { color: #600; font-style: italic } 26 | .typ { color: #404; font-weight: bold } 27 | .lit { color: #044 } 28 | .pun, .opn, .clo { color: #440 } 29 | .tag { color: #006; font-weight: bold } 30 | .atn { color: #404 } 31 | .atv { color: #060 } 32 | } 33 | 34 | /* Put a border around prettyprinted code snippets. */ 35 | pre.prettyprint { padding: 2px; border: 1px solid #888 } 36 | 37 | /* Specify class=linenums on a pre to get line numbering */ 38 | ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */ 39 | li.L0, 40 | li.L1, 41 | li.L2, 42 | li.L3, 43 | li.L5, 44 | li.L6, 45 | li.L7, 46 | li.L8 { list-style-type: none } 47 | /* Alternate shading for lines */ 48 | li.L1, 49 | li.L3, 50 | li.L5, 51 | li.L7, 52 | li.L9 { background: #eee } 53 | -------------------------------------------------------------------------------- /crypt/cfb-demo.phps: -------------------------------------------------------------------------------- 1 | mode == 'ncfb') { 18 | # 19 | #-----[ REPLACE WITH ]---------------------------------- 20 | # 21 | if (false) { 22 | 23 | This departure from mcrypt is inspired by the following discussion at sci.crypt: 24 | 25 | https://groups.google.com/group/sci.crypt/msg/477bd67aceeecab4?hl=ne 26 | */ 27 | include('Crypt/AES.php'); 28 | //define('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL); 29 | 30 | echo CRYPT_AES_MODE == CRYPT_AES_MODE_INTERNAL ? "pure php\r\n" : "mcrypt\r\n"; 31 | 32 | $aes = new Crypt_AES(CRYPT_AES_MODE_CFB); 33 | $aes->enableContinuousBuffer(); 34 | $aes->setKey(str_repeat('a', 24)); 35 | $aes->setIV(str_repeat('b', 8)); 36 | 37 | $aes2= clone $aes; 38 | 39 | $blocks = array(10, 5, 17, 16); 40 | 41 | $total = 0; 42 | foreach ($blocks as $block) { 43 | $total+= $block; 44 | } 45 | 46 | $ciphertext = $aes2->decrypt(str_repeat('c', $total)); 47 | $total = 0; 48 | foreach ($blocks as $block) { 49 | echo bin2hex(substr($ciphertext, $total, $block)) . "\r\n"; 50 | $total+= $block; 51 | } 52 | 53 | echo "\r\n"; 54 | 55 | foreach ($blocks as $block) { 56 | echo bin2hex($aes->decrypt(str_repeat('c', $block))) . "\r\n"; 57 | } -------------------------------------------------------------------------------- /x509/oidparse.phps: -------------------------------------------------------------------------------- 1 | $value) { 59 | echo " '$key' => '$value',\r\n"; 60 | } -------------------------------------------------------------------------------- /math/col3.phps: -------------------------------------------------------------------------------- 1 | loadKey('-----BEGIN PUBLIC KEY----- 22 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylq1ZRSREX7DWHUKg4HX 23 | KGN5C8GQgasXaobkF0J5ok/TfDQnG4WntB/brjQaQRN9phFovHEClj2XywYfL/s9 24 | syHHioaVOIMZ86cLP7xzJc6dF/bydPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4t 25 | XR8FHY1f3pgWwEDXkkMKo/2U5FIIH0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2 26 | AXCiguSHlo14ZEf/dwNlDmEfjBLrJPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V6 27 | 9sh1jPZvEeK8Tw/3E+aC4AoQzOB0VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3 28 | ewIDAQAB 29 | -----END PUBLIC KEY-----'); // public key 30 | 31 | $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); 32 | $ciphertext = $rsa->encrypt($plaintext); 33 | 34 | $rsa->loadKey('-----BEGIN RSA PRIVATE KEY----- 35 | MIIEpQIBAAKCAQEAylq1ZRSREX7DWHUKg4HXKGN5C8GQgasXaobkF0J5ok/TfDQn 36 | G4WntB/brjQaQRN9phFovHEClj2XywYfL/s9syHHioaVOIMZ86cLP7xzJc6dF/by 37 | dPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4tXR8FHY1f3pgWwEDXkkMKo/2U5FII 38 | H0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2AXCiguSHlo14ZEf/dwNlDmEfjBLr 39 | JPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V69sh1jPZvEeK8Tw/3E+aC4AoQzOB0 40 | VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3ewIDAQABAoIBAQDIeuowxRmc/bxI 41 | TV0nQWKLr1Hj5dhnv7ypXA9rQ/8CYpgi/ACq8dZfTRj3FMPWKZtZBvJ/kG+BrnBP 42 | Qzdu8DoG2ba6dfAtVyZFEgDBGtHyaSuW7KD2YPbKEKU7cznhi8vgYEOH+IZyz6tb 43 | OxBmeuNy2SLWTpTnEkOoIhXx4N4P7Y7cTWE3eAnaVNf7moeL12lj6FYp0SwEQbtd 44 | lLCRN/Sts+6zIrQGwGO/+y7GK8LY6IqGZtf95eoGy5+OSnDSpddC5UXUG+9oIcrT 45 | 5N3V1o+t1vYGMl93LO+dGYUugF3O3YQGlxGcJM57Cps57f56bhttZF6FVtsK7DJI 46 | X/vfVMHBAoGBAPHdHZ50HhxgN/yuWPtXTqTeAkVFi1VQAn+BKFiYwyRAiOY68YZX 47 | LwwqXa9Rc1uCUDKXHLGMPGAgZTfb6z19EAsGG08LQbeClZM0Jm1c83skqN8mnbrn 48 | nPSiFc09hSHRLmul195xOkpb0IxZ+8oeljXnbz6IJagzHLP40lvHx/rrAoGBANYu 49 | bwjrRDDWnaQQbPY3Z9fTHx9AD2ErPyVsg+OGvUqDGtTU/32kYR4anUkNaldLcI3k 50 | /QtYgxwE0zcCn9+fmfwYXvIEfmJG1+NH6Mw0rLt15qO6vhZ/fx6ewV0ZtTUvxj2X 51 | yGO5gXE26v3Il+KtlIXm3DBFR5/3+wQIbtaT03GxAoGBAN8dtJoc0j4pANznVQyf 52 | sNvkNcIDcpKD2ZoX4slAOxxxMBj7HR1pxev6FSyK/djX8PWKcxzSmkuu9tC93ld9 53 | zFPvETgs0TXhj+wYuq4+hhn+ao5YyD7INQFzmJsZ+nuExcbmWapJV5WK92rSA7Wj 54 | 27vkQLo1zE9Kv1rC2gNy2+d7AoGBAInpFjfg/WSRHKpipTaZEHVpDNYbcou3xA49 55 | 5GKiBMqwxpsal3R4Xsx6iKJcUAfrnIrRUpp2oN1uwe3e88CTTRyFOMWPXS28vhAr 56 | 4lty43JFhYARo4prCBhYUtu2zPZ1T6mjTTXhYdbbbM6C1kHwUP0zXL58LZV0oJ3F 57 | LFFgmDrRAoGAS9i9FLcipuff0n+1e83rRiE78rAYqA345Y5exakEqfW/orTDfYcq 58 | or0jV1Oh8ZpspoQCEgei9pmP8BoN3j4JCV6sOduXPsRQfIqV7zAFCcIEqxnG1Xhz 59 | vnGFhUKyff8ObWammbWnYnnzXnXRCL+982W8LoOhTzTv7LuSIMq3eOg= 60 | -----END RSA PRIVATE KEY-----'); // private key 61 | echo $rsa->decrypt($ciphertext); 62 | 63 | $elapsed = microtime_float() - $start; 64 | 65 | echo "\r\ntook $elapsed seconds"; -------------------------------------------------------------------------------- /math/col4.phps: -------------------------------------------------------------------------------- 1 | loadKey('-----BEGIN PUBLIC KEY----- 22 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylq1ZRSREX7DWHUKg4HX 23 | KGN5C8GQgasXaobkF0J5ok/TfDQnG4WntB/brjQaQRN9phFovHEClj2XywYfL/s9 24 | syHHioaVOIMZ86cLP7xzJc6dF/bydPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4t 25 | XR8FHY1f3pgWwEDXkkMKo/2U5FIIH0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2 26 | AXCiguSHlo14ZEf/dwNlDmEfjBLrJPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V6 27 | 9sh1jPZvEeK8Tw/3E+aC4AoQzOB0VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3 28 | ewIDAQAB 29 | -----END PUBLIC KEY-----'); // public key 30 | 31 | $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); 32 | $ciphertext = $rsa->encrypt($plaintext); 33 | 34 | $rsa->loadKey('-----BEGIN RSA PRIVATE KEY----- 35 | MIIEpQIBAAKCAQEAylq1ZRSREX7DWHUKg4HXKGN5C8GQgasXaobkF0J5ok/TfDQn 36 | G4WntB/brjQaQRN9phFovHEClj2XywYfL/s9syHHioaVOIMZ86cLP7xzJc6dF/by 37 | dPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4tXR8FHY1f3pgWwEDXkkMKo/2U5FII 38 | H0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2AXCiguSHlo14ZEf/dwNlDmEfjBLr 39 | JPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V69sh1jPZvEeK8Tw/3E+aC4AoQzOB0 40 | VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3ewIDAQABAoIBAQDIeuowxRmc/bxI 41 | TV0nQWKLr1Hj5dhnv7ypXA9rQ/8CYpgi/ACq8dZfTRj3FMPWKZtZBvJ/kG+BrnBP 42 | Qzdu8DoG2ba6dfAtVyZFEgDBGtHyaSuW7KD2YPbKEKU7cznhi8vgYEOH+IZyz6tb 43 | OxBmeuNy2SLWTpTnEkOoIhXx4N4P7Y7cTWE3eAnaVNf7moeL12lj6FYp0SwEQbtd 44 | lLCRN/Sts+6zIrQGwGO/+y7GK8LY6IqGZtf95eoGy5+OSnDSpddC5UXUG+9oIcrT 45 | 5N3V1o+t1vYGMl93LO+dGYUugF3O3YQGlxGcJM57Cps57f56bhttZF6FVtsK7DJI 46 | X/vfVMHBAoGBAPHdHZ50HhxgN/yuWPtXTqTeAkVFi1VQAn+BKFiYwyRAiOY68YZX 47 | LwwqXa9Rc1uCUDKXHLGMPGAgZTfb6z19EAsGG08LQbeClZM0Jm1c83skqN8mnbrn 48 | nPSiFc09hSHRLmul195xOkpb0IxZ+8oeljXnbz6IJagzHLP40lvHx/rrAoGBANYu 49 | bwjrRDDWnaQQbPY3Z9fTHx9AD2ErPyVsg+OGvUqDGtTU/32kYR4anUkNaldLcI3k 50 | /QtYgxwE0zcCn9+fmfwYXvIEfmJG1+NH6Mw0rLt15qO6vhZ/fx6ewV0ZtTUvxj2X 51 | yGO5gXE26v3Il+KtlIXm3DBFR5/3+wQIbtaT03GxAoGBAN8dtJoc0j4pANznVQyf 52 | sNvkNcIDcpKD2ZoX4slAOxxxMBj7HR1pxev6FSyK/djX8PWKcxzSmkuu9tC93ld9 53 | zFPvETgs0TXhj+wYuq4+hhn+ao5YyD7INQFzmJsZ+nuExcbmWapJV5WK92rSA7Wj 54 | 27vkQLo1zE9Kv1rC2gNy2+d7AoGBAInpFjfg/WSRHKpipTaZEHVpDNYbcou3xA49 55 | 5GKiBMqwxpsal3R4Xsx6iKJcUAfrnIrRUpp2oN1uwe3e88CTTRyFOMWPXS28vhAr 56 | 4lty43JFhYARo4prCBhYUtu2zPZ1T6mjTTXhYdbbbM6C1kHwUP0zXL58LZV0oJ3F 57 | LFFgmDrRAoGAS9i9FLcipuff0n+1e83rRiE78rAYqA345Y5exakEqfW/orTDfYcq 58 | or0jV1Oh8ZpspoQCEgei9pmP8BoN3j4JCV6sOduXPsRQfIqV7zAFCcIEqxnG1Xhz 59 | vnGFhUKyff8ObWammbWnYnnzXnXRCL+982W8LoOhTzTv7LuSIMq3eOg= 60 | -----END RSA PRIVATE KEY-----'); // private key 61 | echo $rsa->decrypt($ciphertext); 62 | 63 | $elapsed = microtime_float() - $start; 64 | 65 | echo "\r\ntook $elapsed seconds"; -------------------------------------------------------------------------------- /math/col5.phps: -------------------------------------------------------------------------------- 1 | loadKey('-----BEGIN PUBLIC KEY----- 22 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylq1ZRSREX7DWHUKg4HX 23 | KGN5C8GQgasXaobkF0J5ok/TfDQnG4WntB/brjQaQRN9phFovHEClj2XywYfL/s9 24 | syHHioaVOIMZ86cLP7xzJc6dF/bydPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4t 25 | XR8FHY1f3pgWwEDXkkMKo/2U5FIIH0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2 26 | AXCiguSHlo14ZEf/dwNlDmEfjBLrJPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V6 27 | 9sh1jPZvEeK8Tw/3E+aC4AoQzOB0VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3 28 | ewIDAQAB 29 | -----END PUBLIC KEY-----'); // public key 30 | 31 | $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); 32 | $ciphertext = $rsa->encrypt($plaintext); 33 | 34 | $rsa->loadKey('-----BEGIN RSA PRIVATE KEY----- 35 | MIIEpQIBAAKCAQEAylq1ZRSREX7DWHUKg4HXKGN5C8GQgasXaobkF0J5ok/TfDQn 36 | G4WntB/brjQaQRN9phFovHEClj2XywYfL/s9syHHioaVOIMZ86cLP7xzJc6dF/by 37 | dPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4tXR8FHY1f3pgWwEDXkkMKo/2U5FII 38 | H0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2AXCiguSHlo14ZEf/dwNlDmEfjBLr 39 | JPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V69sh1jPZvEeK8Tw/3E+aC4AoQzOB0 40 | VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3ewIDAQABAoIBAQDIeuowxRmc/bxI 41 | TV0nQWKLr1Hj5dhnv7ypXA9rQ/8CYpgi/ACq8dZfTRj3FMPWKZtZBvJ/kG+BrnBP 42 | Qzdu8DoG2ba6dfAtVyZFEgDBGtHyaSuW7KD2YPbKEKU7cznhi8vgYEOH+IZyz6tb 43 | OxBmeuNy2SLWTpTnEkOoIhXx4N4P7Y7cTWE3eAnaVNf7moeL12lj6FYp0SwEQbtd 44 | lLCRN/Sts+6zIrQGwGO/+y7GK8LY6IqGZtf95eoGy5+OSnDSpddC5UXUG+9oIcrT 45 | 5N3V1o+t1vYGMl93LO+dGYUugF3O3YQGlxGcJM57Cps57f56bhttZF6FVtsK7DJI 46 | X/vfVMHBAoGBAPHdHZ50HhxgN/yuWPtXTqTeAkVFi1VQAn+BKFiYwyRAiOY68YZX 47 | LwwqXa9Rc1uCUDKXHLGMPGAgZTfb6z19EAsGG08LQbeClZM0Jm1c83skqN8mnbrn 48 | nPSiFc09hSHRLmul195xOkpb0IxZ+8oeljXnbz6IJagzHLP40lvHx/rrAoGBANYu 49 | bwjrRDDWnaQQbPY3Z9fTHx9AD2ErPyVsg+OGvUqDGtTU/32kYR4anUkNaldLcI3k 50 | /QtYgxwE0zcCn9+fmfwYXvIEfmJG1+NH6Mw0rLt15qO6vhZ/fx6ewV0ZtTUvxj2X 51 | yGO5gXE26v3Il+KtlIXm3DBFR5/3+wQIbtaT03GxAoGBAN8dtJoc0j4pANznVQyf 52 | sNvkNcIDcpKD2ZoX4slAOxxxMBj7HR1pxev6FSyK/djX8PWKcxzSmkuu9tC93ld9 53 | zFPvETgs0TXhj+wYuq4+hhn+ao5YyD7INQFzmJsZ+nuExcbmWapJV5WK92rSA7Wj 54 | 27vkQLo1zE9Kv1rC2gNy2+d7AoGBAInpFjfg/WSRHKpipTaZEHVpDNYbcou3xA49 55 | 5GKiBMqwxpsal3R4Xsx6iKJcUAfrnIrRUpp2oN1uwe3e88CTTRyFOMWPXS28vhAr 56 | 4lty43JFhYARo4prCBhYUtu2zPZ1T6mjTTXhYdbbbM6C1kHwUP0zXL58LZV0oJ3F 57 | LFFgmDrRAoGAS9i9FLcipuff0n+1e83rRiE78rAYqA345Y5exakEqfW/orTDfYcq 58 | or0jV1Oh8ZpspoQCEgei9pmP8BoN3j4JCV6sOduXPsRQfIqV7zAFCcIEqxnG1Xhz 59 | vnGFhUKyff8ObWammbWnYnnzXnXRCL+982W8LoOhTzTv7LuSIMq3eOg= 60 | -----END RSA PRIVATE KEY-----'); // private key 61 | echo $rsa->decrypt($ciphertext); 62 | 63 | $elapsed = microtime_float() - $start; 64 | 65 | echo "\r\ntook $elapsed seconds"; -------------------------------------------------------------------------------- /css/jquery.treeview.css: -------------------------------------------------------------------------------- 1 | .treeview, .treeview ul { 2 | padding: 0; 3 | margin: 0; 4 | list-style: none; 5 | } 6 | 7 | .treeview ul { 8 | background-color: white; 9 | margin-top: 4px; 10 | } 11 | 12 | .treeview .hitarea { 13 | background: url(../images/treeview-default.gif) -64px -25px no-repeat; 14 | height: 16px; 15 | width: 16px; 16 | margin-left: -16px; 17 | float: left; 18 | cursor: pointer; 19 | } 20 | /* fix for IE6 */ 21 | * html .hitarea { 22 | display: inline; 23 | float:none; 24 | } 25 | 26 | .treeview li { 27 | margin: 0; 28 | padding: 3px 0pt 3px 16px; 29 | } 30 | 31 | .treeview a.selected { 32 | background-color: #eee; 33 | } 34 | 35 | #treecontrol { margin: 1em 0; display: none; } 36 | 37 | .treeview .hover { color: red; cursor: pointer; } 38 | 39 | .treeview li { background: url(../images/treeview-new.gif) 0 0 repeat-y } 40 | .treeview li.collapsable, .treeview li.expandable { background: url(../images/treeview-default-line.gif) 0 -176 no-repeat; } 41 | 42 | .treeview .expandable-hitarea { background-position: -80px -3px; } 43 | 44 | .treeview li.last { background: url(../images/treeview-default-line.gif) 0 -1766px no-repeat; } 45 | .treeview li.lastCollapsable, .treeview li.lastExpandable { background: url(../images/treeview-default.gif) 0 0 no-repeat; } 46 | .treeview li.lastCollapsable { background-position: 0 -111px } 47 | .treeview li.lastExpandable { background-position: -32px -67px } 48 | 49 | .treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; } 50 | 51 | .treeview-red li { background-image: url(images/treeview-red-line.gif); } 52 | .treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(../images/treeview-red.gif); } 53 | 54 | .treeview-black li { background-image: url(../images/treeview-black-line.gif); } 55 | .treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(../images/treeview-black.gif); } 56 | 57 | .treeview-gray li { background-image: url(../images/treeview-gray-line.gif); } 58 | .treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(../images/treeview-gray.gif); } 59 | 60 | .treeview-famfamfam li { background-image: url(../images/treeview-famfamfam-line.gif); } 61 | .treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(../images/treeview-famfamfam.gif); } 62 | 63 | .treeview .placeholder { 64 | background: url(../images/ajax-loader.gif) 0 0 no-repeat; 65 | height: 16px; 66 | width: 16px; 67 | display: block; 68 | } 69 | 70 | .filetree li { padding: 3px 0 2px 16px; } 71 | .filetree span.folder, .filetree span.file { padding: 1px 0 1px 16px; display: block; } 72 | .filetree span.folder { background: url(../images/folder.gif) 0 0 no-repeat; } 73 | .filetree li.expandable span.folder { background: url(../images/folder-closed.gif) 0 0 no-repeat; } 74 | .filetree span.file { background: url(../images/file.gif) 0 0 no-repeat; } 75 | -------------------------------------------------------------------------------- /math/col1.phps: -------------------------------------------------------------------------------- 1 | loadKey('-----BEGIN PUBLIC KEY----- 23 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylq1ZRSREX7DWHUKg4HX 24 | KGN5C8GQgasXaobkF0J5ok/TfDQnG4WntB/brjQaQRN9phFovHEClj2XywYfL/s9 25 | syHHioaVOIMZ86cLP7xzJc6dF/bydPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4t 26 | XR8FHY1f3pgWwEDXkkMKo/2U5FIIH0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2 27 | AXCiguSHlo14ZEf/dwNlDmEfjBLrJPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V6 28 | 9sh1jPZvEeK8Tw/3E+aC4AoQzOB0VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3 29 | ewIDAQAB 30 | -----END PUBLIC KEY-----'); // public key 31 | 32 | $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); 33 | $ciphertext = $rsa->encrypt($plaintext); 34 | 35 | $rsa->loadKey('-----BEGIN RSA PRIVATE KEY----- 36 | MIIEpQIBAAKCAQEAylq1ZRSREX7DWHUKg4HXKGN5C8GQgasXaobkF0J5ok/TfDQn 37 | G4WntB/brjQaQRN9phFovHEClj2XywYfL/s9syHHioaVOIMZ86cLP7xzJc6dF/by 38 | dPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4tXR8FHY1f3pgWwEDXkkMKo/2U5FII 39 | H0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2AXCiguSHlo14ZEf/dwNlDmEfjBLr 40 | JPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V69sh1jPZvEeK8Tw/3E+aC4AoQzOB0 41 | VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3ewIDAQABAoIBAQDIeuowxRmc/bxI 42 | TV0nQWKLr1Hj5dhnv7ypXA9rQ/8CYpgi/ACq8dZfTRj3FMPWKZtZBvJ/kG+BrnBP 43 | Qzdu8DoG2ba6dfAtVyZFEgDBGtHyaSuW7KD2YPbKEKU7cznhi8vgYEOH+IZyz6tb 44 | OxBmeuNy2SLWTpTnEkOoIhXx4N4P7Y7cTWE3eAnaVNf7moeL12lj6FYp0SwEQbtd 45 | lLCRN/Sts+6zIrQGwGO/+y7GK8LY6IqGZtf95eoGy5+OSnDSpddC5UXUG+9oIcrT 46 | 5N3V1o+t1vYGMl93LO+dGYUugF3O3YQGlxGcJM57Cps57f56bhttZF6FVtsK7DJI 47 | X/vfVMHBAoGBAPHdHZ50HhxgN/yuWPtXTqTeAkVFi1VQAn+BKFiYwyRAiOY68YZX 48 | LwwqXa9Rc1uCUDKXHLGMPGAgZTfb6z19EAsGG08LQbeClZM0Jm1c83skqN8mnbrn 49 | nPSiFc09hSHRLmul195xOkpb0IxZ+8oeljXnbz6IJagzHLP40lvHx/rrAoGBANYu 50 | bwjrRDDWnaQQbPY3Z9fTHx9AD2ErPyVsg+OGvUqDGtTU/32kYR4anUkNaldLcI3k 51 | /QtYgxwE0zcCn9+fmfwYXvIEfmJG1+NH6Mw0rLt15qO6vhZ/fx6ewV0ZtTUvxj2X 52 | yGO5gXE26v3Il+KtlIXm3DBFR5/3+wQIbtaT03GxAoGBAN8dtJoc0j4pANznVQyf 53 | sNvkNcIDcpKD2ZoX4slAOxxxMBj7HR1pxev6FSyK/djX8PWKcxzSmkuu9tC93ld9 54 | zFPvETgs0TXhj+wYuq4+hhn+ao5YyD7INQFzmJsZ+nuExcbmWapJV5WK92rSA7Wj 55 | 27vkQLo1zE9Kv1rC2gNy2+d7AoGBAInpFjfg/WSRHKpipTaZEHVpDNYbcou3xA49 56 | 5GKiBMqwxpsal3R4Xsx6iKJcUAfrnIrRUpp2oN1uwe3e88CTTRyFOMWPXS28vhAr 57 | 4lty43JFhYARo4prCBhYUtu2zPZ1T6mjTTXhYdbbbM6C1kHwUP0zXL58LZV0oJ3F 58 | LFFgmDrRAoGAS9i9FLcipuff0n+1e83rRiE78rAYqA345Y5exakEqfW/orTDfYcq 59 | or0jV1Oh8ZpspoQCEgei9pmP8BoN3j4JCV6sOduXPsRQfIqV7zAFCcIEqxnG1Xhz 60 | vnGFhUKyff8ObWammbWnYnnzXnXRCL+982W8LoOhTzTv7LuSIMq3eOg= 61 | -----END RSA PRIVATE KEY-----'); // private key 62 | echo $rsa->decrypt($ciphertext); 63 | 64 | $elapsed = microtime_float() - $start; 65 | 66 | echo "\r\ntook $elapsed seconds"; -------------------------------------------------------------------------------- /math/col2.phps: -------------------------------------------------------------------------------- 1 | loadKey('-----BEGIN PUBLIC KEY----- 23 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylq1ZRSREX7DWHUKg4HX 24 | KGN5C8GQgasXaobkF0J5ok/TfDQnG4WntB/brjQaQRN9phFovHEClj2XywYfL/s9 25 | syHHioaVOIMZ86cLP7xzJc6dF/bydPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4t 26 | XR8FHY1f3pgWwEDXkkMKo/2U5FIIH0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2 27 | AXCiguSHlo14ZEf/dwNlDmEfjBLrJPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V6 28 | 9sh1jPZvEeK8Tw/3E+aC4AoQzOB0VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3 29 | ewIDAQAB 30 | -----END PUBLIC KEY-----'); // public key 31 | 32 | $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); 33 | $ciphertext = $rsa->encrypt($plaintext); 34 | 35 | $rsa->loadKey('-----BEGIN RSA PRIVATE KEY----- 36 | MIIEpQIBAAKCAQEAylq1ZRSREX7DWHUKg4HXKGN5C8GQgasXaobkF0J5ok/TfDQn 37 | G4WntB/brjQaQRN9phFovHEClj2XywYfL/s9syHHioaVOIMZ86cLP7xzJc6dF/by 38 | dPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4tXR8FHY1f3pgWwEDXkkMKo/2U5FII 39 | H0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2AXCiguSHlo14ZEf/dwNlDmEfjBLr 40 | JPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V69sh1jPZvEeK8Tw/3E+aC4AoQzOB0 41 | VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3ewIDAQABAoIBAQDIeuowxRmc/bxI 42 | TV0nQWKLr1Hj5dhnv7ypXA9rQ/8CYpgi/ACq8dZfTRj3FMPWKZtZBvJ/kG+BrnBP 43 | Qzdu8DoG2ba6dfAtVyZFEgDBGtHyaSuW7KD2YPbKEKU7cznhi8vgYEOH+IZyz6tb 44 | OxBmeuNy2SLWTpTnEkOoIhXx4N4P7Y7cTWE3eAnaVNf7moeL12lj6FYp0SwEQbtd 45 | lLCRN/Sts+6zIrQGwGO/+y7GK8LY6IqGZtf95eoGy5+OSnDSpddC5UXUG+9oIcrT 46 | 5N3V1o+t1vYGMl93LO+dGYUugF3O3YQGlxGcJM57Cps57f56bhttZF6FVtsK7DJI 47 | X/vfVMHBAoGBAPHdHZ50HhxgN/yuWPtXTqTeAkVFi1VQAn+BKFiYwyRAiOY68YZX 48 | LwwqXa9Rc1uCUDKXHLGMPGAgZTfb6z19EAsGG08LQbeClZM0Jm1c83skqN8mnbrn 49 | nPSiFc09hSHRLmul195xOkpb0IxZ+8oeljXnbz6IJagzHLP40lvHx/rrAoGBANYu 50 | bwjrRDDWnaQQbPY3Z9fTHx9AD2ErPyVsg+OGvUqDGtTU/32kYR4anUkNaldLcI3k 51 | /QtYgxwE0zcCn9+fmfwYXvIEfmJG1+NH6Mw0rLt15qO6vhZ/fx6ewV0ZtTUvxj2X 52 | yGO5gXE26v3Il+KtlIXm3DBFR5/3+wQIbtaT03GxAoGBAN8dtJoc0j4pANznVQyf 53 | sNvkNcIDcpKD2ZoX4slAOxxxMBj7HR1pxev6FSyK/djX8PWKcxzSmkuu9tC93ld9 54 | zFPvETgs0TXhj+wYuq4+hhn+ao5YyD7INQFzmJsZ+nuExcbmWapJV5WK92rSA7Wj 55 | 27vkQLo1zE9Kv1rC2gNy2+d7AoGBAInpFjfg/WSRHKpipTaZEHVpDNYbcou3xA49 56 | 5GKiBMqwxpsal3R4Xsx6iKJcUAfrnIrRUpp2oN1uwe3e88CTTRyFOMWPXS28vhAr 57 | 4lty43JFhYARo4prCBhYUtu2zPZ1T6mjTTXhYdbbbM6C1kHwUP0zXL58LZV0oJ3F 58 | LFFgmDrRAoGAS9i9FLcipuff0n+1e83rRiE78rAYqA345Y5exakEqfW/orTDfYcq 59 | or0jV1Oh8ZpspoQCEgei9pmP8BoN3j4JCV6sOduXPsRQfIqV7zAFCcIEqxnG1Xhz 60 | vnGFhUKyff8ObWammbWnYnnzXnXRCL+982W8LoOhTzTv7LuSIMq3eOg= 61 | -----END RSA PRIVATE KEY-----'); // private key 62 | echo $rsa->decrypt($ciphertext); 63 | 64 | $elapsed = microtime_float() - $start; 65 | 66 | echo "\r\ntook $elapsed seconds"; -------------------------------------------------------------------------------- /math/speed.phps: -------------------------------------------------------------------------------- 1 | loadKey('-----BEGIN PUBLIC KEY----- 23 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAylq1ZRSREX7DWHUKg4HX 24 | KGN5C8GQgasXaobkF0J5ok/TfDQnG4WntB/brjQaQRN9phFovHEClj2XywYfL/s9 25 | syHHioaVOIMZ86cLP7xzJc6dF/bydPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4t 26 | XR8FHY1f3pgWwEDXkkMKo/2U5FIIH0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2 27 | AXCiguSHlo14ZEf/dwNlDmEfjBLrJPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V6 28 | 9sh1jPZvEeK8Tw/3E+aC4AoQzOB0VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3 29 | ewIDAQAB 30 | -----END PUBLIC KEY-----'); // public key 31 | 32 | $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); 33 | $ciphertext = $rsa->encrypt($plaintext); 34 | 35 | $rsa->loadKey('-----BEGIN RSA PRIVATE KEY----- 36 | MIIEpQIBAAKCAQEAylq1ZRSREX7DWHUKg4HXKGN5C8GQgasXaobkF0J5ok/TfDQn 37 | G4WntB/brjQaQRN9phFovHEClj2XywYfL/s9syHHioaVOIMZ86cLP7xzJc6dF/by 38 | dPLD1p14DkpJLgCSx6CyTlFzOhmm4/YMEh4tXR8FHY1f3pgWwEDXkkMKo/2U5FII 39 | H0HBfnXgZeYSw7DalriaiZ+PyxpnqfYA5TT2AXCiguSHlo14ZEf/dwNlDmEfjBLr 40 | JPltOp69ZlqZYeykuEjg54KbvR2EMjQWj3V69sh1jPZvEeK8Tw/3E+aC4AoQzOB0 41 | VLF56yn1yfMZFvBRYd6RAhtcoU7Lli3/J7c3ewIDAQABAoIBAQDIeuowxRmc/bxI 42 | TV0nQWKLr1Hj5dhnv7ypXA9rQ/8CYpgi/ACq8dZfTRj3FMPWKZtZBvJ/kG+BrnBP 43 | Qzdu8DoG2ba6dfAtVyZFEgDBGtHyaSuW7KD2YPbKEKU7cznhi8vgYEOH+IZyz6tb 44 | OxBmeuNy2SLWTpTnEkOoIhXx4N4P7Y7cTWE3eAnaVNf7moeL12lj6FYp0SwEQbtd 45 | lLCRN/Sts+6zIrQGwGO/+y7GK8LY6IqGZtf95eoGy5+OSnDSpddC5UXUG+9oIcrT 46 | 5N3V1o+t1vYGMl93LO+dGYUugF3O3YQGlxGcJM57Cps57f56bhttZF6FVtsK7DJI 47 | X/vfVMHBAoGBAPHdHZ50HhxgN/yuWPtXTqTeAkVFi1VQAn+BKFiYwyRAiOY68YZX 48 | LwwqXa9Rc1uCUDKXHLGMPGAgZTfb6z19EAsGG08LQbeClZM0Jm1c83skqN8mnbrn 49 | nPSiFc09hSHRLmul195xOkpb0IxZ+8oeljXnbz6IJagzHLP40lvHx/rrAoGBANYu 50 | bwjrRDDWnaQQbPY3Z9fTHx9AD2ErPyVsg+OGvUqDGtTU/32kYR4anUkNaldLcI3k 51 | /QtYgxwE0zcCn9+fmfwYXvIEfmJG1+NH6Mw0rLt15qO6vhZ/fx6ewV0ZtTUvxj2X 52 | yGO5gXE26v3Il+KtlIXm3DBFR5/3+wQIbtaT03GxAoGBAN8dtJoc0j4pANznVQyf 53 | sNvkNcIDcpKD2ZoX4slAOxxxMBj7HR1pxev6FSyK/djX8PWKcxzSmkuu9tC93ld9 54 | zFPvETgs0TXhj+wYuq4+hhn+ao5YyD7INQFzmJsZ+nuExcbmWapJV5WK92rSA7Wj 55 | 27vkQLo1zE9Kv1rC2gNy2+d7AoGBAInpFjfg/WSRHKpipTaZEHVpDNYbcou3xA49 56 | 5GKiBMqwxpsal3R4Xsx6iKJcUAfrnIrRUpp2oN1uwe3e88CTTRyFOMWPXS28vhAr 57 | 4lty43JFhYARo4prCBhYUtu2zPZ1T6mjTTXhYdbbbM6C1kHwUP0zXL58LZV0oJ3F 58 | LFFgmDrRAoGAS9i9FLcipuff0n+1e83rRiE78rAYqA345Y5exakEqfW/orTDfYcq 59 | or0jV1Oh8ZpspoQCEgei9pmP8BoN3j4JCV6sOduXPsRQfIqV7zAFCcIEqxnG1Xhz 60 | vnGFhUKyff8ObWammbWnYnnzXnXRCL+982W8LoOhTzTv7LuSIMq3eOg= 61 | -----END RSA PRIVATE KEY-----'); // private key 62 | echo $rsa->decrypt($ciphertext); 63 | 64 | $elapsed = microtime_float() - $start; 65 | 66 | echo "\r\ntook $elapsed seconds"; -------------------------------------------------------------------------------- /css/reset.css: -------------------------------------------------------------------------------- 1 | /* `XHTML, HTML4, HTML5 Reset 2 | ----------------------------------------------------------------------------------------------------*/ 3 | 4 | a, 5 | abbr, 6 | acronym, 7 | address, 8 | applet, 9 | article, 10 | aside, 11 | audio, 12 | b, 13 | big, 14 | blockquote, 15 | body, 16 | canvas, 17 | caption, 18 | center, 19 | cite, 20 | code, 21 | dd, 22 | del, 23 | details, 24 | dfn, 25 | dialog, 26 | div, 27 | dl, 28 | dt, 29 | em, 30 | embed, 31 | fieldset, 32 | figcaption, 33 | figure, 34 | font, 35 | footer, 36 | form, 37 | h1, 38 | h2, 39 | h3, 40 | h4, 41 | h5, 42 | h6, 43 | header, 44 | hgroup, 45 | hr, 46 | html, 47 | i, 48 | iframe, 49 | img, 50 | ins, 51 | kbd, 52 | label, 53 | legend, 54 | li, 55 | mark, 56 | menu, 57 | meter, 58 | nav, 59 | object, 60 | ol, 61 | output, 62 | p, 63 | pre, 64 | progress, 65 | q, 66 | rp, 67 | rt, 68 | ruby, 69 | s, 70 | samp, 71 | section, 72 | small, 73 | span, 74 | strike, 75 | strong, 76 | sub, 77 | summary, 78 | sup, 79 | table, 80 | tbody, 81 | td, 82 | tfoot, 83 | th, 84 | thead, 85 | time, 86 | tr, 87 | tt, 88 | u, 89 | ul, 90 | var, 91 | video, 92 | xmp { 93 | border: 0; 94 | margin: 0; 95 | padding: 0; 96 | font-size: 100%; 97 | } 98 | 99 | html, 100 | body { 101 | height: 100%; 102 | } 103 | 104 | article, 105 | aside, 106 | details, 107 | figcaption, 108 | figure, 109 | footer, 110 | header, 111 | hgroup, 112 | menu, 113 | nav, 114 | section { 115 | /* 116 | Override the default (display: inline) for 117 | browsers that do not recognize HTML5 tags. 118 | 119 | IE8 (and lower) requires a shiv: 120 | http://ejohn.org/blog/html5-shiv 121 | */ 122 | display: block; 123 | } 124 | 125 | b, 126 | strong { 127 | /* 128 | Makes browsers agree. 129 | IE + Opera = font-weight: bold. 130 | Gecko + WebKit = font-weight: bolder. 131 | */ 132 | font-weight: bold; 133 | } 134 | 135 | img { 136 | color: transparent; 137 | font-size: 0; 138 | vertical-align: middle; 139 | /* 140 | For IE. 141 | http://css-tricks.com/ie-fix-bicubic-scaling-for-images 142 | */ 143 | -ms-interpolation-mode: bicubic; 144 | } 145 | 146 | ol, 147 | ul { 148 | list-style: none; 149 | } 150 | 151 | li { 152 | /* 153 | For IE6 + IE7: 154 | 155 | "display: list-item" keeps bullets from 156 | disappearing if hasLayout is triggered. 157 | */ 158 | display: list-item; 159 | } 160 | 161 | table { 162 | border-collapse: collapse; 163 | border-spacing: 0; 164 | } 165 | 166 | th, 167 | td, 168 | caption { 169 | font-weight: normal; 170 | vertical-align: top; 171 | text-align: left; 172 | } 173 | 174 | q { 175 | quotes: none; 176 | } 177 | 178 | q:before, 179 | q:after { 180 | content: ''; 181 | content: none; 182 | } 183 | 184 | sub, 185 | sup, 186 | small { 187 | font-size: 75%; 188 | } 189 | 190 | sub, 191 | sup { 192 | line-height: 0; 193 | position: relative; 194 | vertical-align: baseline; 195 | } 196 | 197 | sub { 198 | bottom: -0.25em; 199 | } 200 | 201 | sup { 202 | top: -0.5em; 203 | } 204 | 205 | svg { 206 | /* 207 | For IE9. Without, occasionally draws shapes 208 | outside the boundaries of rectangle. 209 | */ 210 | overflow: hidden; 211 | } -------------------------------------------------------------------------------- /js/common.js: -------------------------------------------------------------------------------- 1 | var ver = Cookies.get('version'); 2 | var parts = window.location.pathname.split('/'); 3 | if (ver == '2.0' && parts[2] != '2.0') { 4 | window.location = parts[0] + '/' + parts[1] + '/2.0/' + parts[2] + window.location.hash; 5 | } else if (ver == '1.0' && parts[2] == '2.0') { 6 | window.location = parts[0] + '/' + parts[1] + '/' + parts[3] + window.location.hash; 7 | } else if (ver == '3.0') { 8 | window.location = 'https://phpseclib.com/'; 9 | } 10 | 11 | var manageSelects = function() { 12 | options = $('select option').not('#versionsel'); 13 | for (var i = 0; i < options.length; i++) { 14 | $('.' + options[i].value).hide(); 15 | } 16 | 17 | options = $('select option:selected').not('#versionsel'); 18 | for (var i = 0; i < options.length; i++) { 19 | $('.' + options[i].value).show(); 20 | } 21 | }; 22 | 23 | var highlight = function() { 24 | if ($('.' + this.value).closest('#notes').length == 0) { 25 | $('.' + this.value).css('background-color', '#ffa'); 26 | } 27 | }; 28 | 29 | var unhighlight = function() { 30 | if ($('.' + this.value).closest('#notes').length == 0) { 31 | $('.' + this.value).css('background-color', '#f5f4ee'); 32 | } 33 | }; 34 | 35 | var toggleButton = function() { 36 | buttons = $('button[value="' + this.value + '"]'); 37 | buttons.eq(0).toggle(); 38 | buttons.eq(1).toggle(); 39 | $('.' + this.value).toggle(); 40 | }; 41 | 42 | var permLink = function() { 43 | attrs = ''; 44 | selected = $('select option:selected,.disableCode:visible').not('#versionsel'); 45 | for (i = 0; i < selected.length; i++) { 46 | attrs+= selected[i].value + ','; 47 | } 48 | hashPos = window.location.href.indexOf('#'); 49 | newURL = hashPos == -1 ? window.location.href : window.location.href.substring(0, hashPos); 50 | window.location.href = newURL + '#' + attrs; 51 | }; 52 | 53 | $(document).ready(function() { 54 | //$('pre span[id]').hide(); 55 | //$('#notes div[id]').hide(); 56 | 57 | buttons = $('button:visible').not('#versionnext'); 58 | for (var i = 0; i < buttons.length; i++) { 59 | $('.' + buttons[i].value).hide(); 60 | } 61 | 62 | options = window.location.href.split('#'); 63 | options = options.length > 1 ? options[1].split(',') : new Array(); 64 | for (var i = 0; i < options.length; i++) { 65 | options[i] = options[i].replace(/%20/g, ' '); 66 | $('select option[value="' + options[i] +'"]').prop('selected', true); 67 | button = $('button[value="' + options[i] +'"]'); 68 | if (button.length) { 69 | toggleButton.apply(button[0]); 70 | } 71 | } 72 | 73 | manageSelects(); 74 | 75 | $('select').change(manageSelects); 76 | //$('select').change(highlight); 77 | $('select').keyup(manageSelects); 78 | //$('select').focus(highlight); 79 | //$('select').blur(unhighlight); 80 | $('button').not('#versionnext').click(toggleButton); 81 | $('#permlink span').click(permLink); 82 | 83 | if (!Cookies.get('version')) { 84 | $('#version').show(); 85 | $('#version').dialog({ 86 | //height: 200, 87 | modal: true 88 | }); 89 | } 90 | 91 | $('#versionnext').click(function() { 92 | var ver = $('#versionsel').val(); 93 | Cookies.set('version', ver, { path: '/' }); 94 | $('#version').dialog('close'); 95 | var parts = window.location.pathname.split('/'); 96 | if (ver == '2.0' && parts[2] != '2.0') { 97 | window.location = parts[0] + '/' + parts[1] + '/2.0/' + parts[2] + window.location.hash; 98 | } else if (ver == '1.0' && parts[2] == '2.0') { 99 | window.location = parts[0] + '/' + parts[1] + '/' + parts[3] + window.location.hash; 100 | } else if (ver == '3.0') { 101 | window.location = 'https://phpseclib.com/'; 102 | } 103 | }); 104 | }); -------------------------------------------------------------------------------- /2.0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | phpseclib 2.0.x examples | phpseclib 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 57 | 58 | 59 |
60 |
61 |

phpseclib 2.0 examples

62 | 63 |
64 |
65 | Download phpseclib 66 |
67 |
68 |
69 |

Examples:

70 | 73 |
74 |
75 |

These examples utilize Composer's autoloader

76 |

Log into SSH server with RSA key

77 |
<?php
 78 | include 'autoload.php';
 79 | 
 80 | $loader = new \Composer\Autoload\ClassLoader();
 81 | $loader->addPsr4('phpseclib\\', __DIR__ . '/path/to/phpseclib2.0');
 82 | $loader->register();
 83 | 
 84 | use phpseclib\Crypt\RSA;
 85 | use phpseclib\Net\SSH2;
 86 | 
 87 | $key = new RSA();
 88 | $key->loadKey(file_get_contents('private-key.txt'));
 89 | 
 90 | // Domain can be an IP too
 91 | $ssh = new SSH2('www.domain.tld');
 92 | if (!$ssh->login('username', $key)) {
 93 |     exit('Login Failed');
 94 | }
 95 | 
 96 | echo $ssh->exec('pwd');
 97 | echo $ssh->exec('ls -la');
 98 |     
99 |
100 | 101 |
102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /js/jquery.cookie.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Cookie plugin 3 | * 4 | * Copyright (c) 2006 Klaus Hartl (stilbuero.de) 5 | * Dual licensed under the MIT and GPL licenses: 6 | * http://www.opensource.org/licenses/mit-license.php 7 | * http://www.gnu.org/licenses/gpl.html 8 | * 9 | */ 10 | 11 | /** 12 | * Create a cookie with the given name and value and other optional parameters. 13 | * 14 | * @example $.cookie('the_cookie', 'the_value'); 15 | * @desc Set the value of a cookie. 16 | * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true}); 17 | * @desc Create a cookie with all available options. 18 | * @example $.cookie('the_cookie', 'the_value'); 19 | * @desc Create a session cookie. 20 | * @example $.cookie('the_cookie', null); 21 | * @desc Delete a cookie by passing null as value. 22 | * 23 | * @param String name The name of the cookie. 24 | * @param String value The value of the cookie. 25 | * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. 26 | * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. 27 | * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. 28 | * If set to null or omitted, the cookie will be a session cookie and will not be retained 29 | * when the the browser exits. 30 | * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). 31 | * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). 32 | * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will 33 | * require a secure protocol (like HTTPS). 34 | * @type undefined 35 | * 36 | * @name $.cookie 37 | * @cat Plugins/Cookie 38 | * @author Klaus Hartl/klaus.hartl@stilbuero.de 39 | */ 40 | 41 | /** 42 | * Get the value of a cookie with the given name. 43 | * 44 | * @example $.cookie('the_cookie'); 45 | * @desc Get the value of a cookie. 46 | * 47 | * @param String name The name of the cookie. 48 | * @return The value of the cookie. 49 | * @type String 50 | * 51 | * @name $.cookie 52 | * @cat Plugins/Cookie 53 | * @author Klaus Hartl/klaus.hartl@stilbuero.de 54 | */ 55 | jQuery.cookie = function(name, value, options) { 56 | if (typeof value != 'undefined') { // name and value given, set cookie 57 | options = options || {}; 58 | if (value === null) { 59 | value = ''; 60 | options.expires = -1; 61 | } 62 | var expires = ''; 63 | if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { 64 | var date; 65 | if (typeof options.expires == 'number') { 66 | date = new Date(); 67 | date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); 68 | } else { 69 | date = options.expires; 70 | } 71 | expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE 72 | } 73 | var path = options.path ? '; path=' + options.path : ''; 74 | var domain = options.domain ? '; domain=' + options.domain : ''; 75 | var secure = options.secure ? '; secure' : ''; 76 | document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); 77 | } else { // only name given, get cookie 78 | var cookieValue = null; 79 | if (document.cookie && document.cookie != '') { 80 | var cookies = document.cookie.split(';'); 81 | for (var i = 0; i < cookies.length; i++) { 82 | var cookie = jQuery.trim(cookies[i]); 83 | // Does this cookie string begin with the name we want? 84 | if (cookie.substring(0, name.length + 1) == (name + '=')) { 85 | cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 86 | break; 87 | } 88 | } 89 | } 90 | return cookieValue; 91 | } 92 | }; -------------------------------------------------------------------------------- /sftp/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | SFTP Introduction | phpseclib 33 | 34 | 35 | 36 | 37 | 47 | 48 |
49 |
50 |

phpseclib: SFTP Feature List

51 | 52 |

Click on any of the following for examples.

53 |
54 |
55 | Download Now 56 |
57 |
58 |
59 |

SFTP extends SSH2

60 |

SFTP has all the functions SSH2 has and then some.

61 |
62 |
63 |

Features

64 | 106 |
107 | 108 |
109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /x509/asn1tutorial.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 21 | asn1parse Interpretation Guide | phpseclib 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 45 | 46 |
47 |
48 |

phpseclib: asn1parse Interpretation Guide

49 | 50 |
51 |
52 |
53 |   54 |
55 | 56 |
57 |

asn1parse Interpretation Guide

58 |

Let's say you're trying to decode this:

59 |
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCunhp5XEEptnE/+jhfdTF1ryjr 
60 | 756tUJs26RTKgVa/6isdO+SzTdHRvsOqle8Ze58Y9Qj8goVGkcsxrSHr+nEWcN6O 
61 | oQK+e1Inux5PDwVOE9kiWbjDN4hs41+d6ZgdN6l8h4bhPeAVgQoS2F4a2TKMyLY5 
62 | dyzwj7RK98mLwbfaNwIDAQAB
63 |

Here's the ASN.1 decoding you'll get back:

64 |
    0:d=0  hl=3 l= 159 cons: SEQUENCE 
65 |     3:d=1  hl=2 l=  13 cons:  SEQUENCE 
66 |     5:d=2  hl=2 l=   9 prim:   OBJECT            :rsaEncryption 
67 |    16:d=2  hl=2 l=   0 prim:   NULL 
68 |    18:d=1  hl=3 l= 141 prim:  BIT STRING
69 |

Great. So you have an RSA public key. But what is contained within BIT STRING?

70 |

To figure that out let's first explain the format of the output.

71 |

Consider this line:

72 |
   18:d=1  hl=3 l= 141 prim:  BIT STRING
73 |

18 is the offset from the beginning, d=1 is the depth and hl=3 is the header length.

74 |

Here's how you can isolate the BIT STRING:

75 |
<?php 
76 | $data = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCunhp5XEEptnE/+jhfdTF1ryjr 
77 | 756tUJs26RTKgVa/6isdO+SzTdHRvsOqle8Ze58Y9Qj8goVGkcsxrSHr+nEWcN6O 
78 | oQK+e1Inux5PDwVOE9kiWbjDN4hs41+d6ZgdN6l8h4bhPeAVgQoS2F4a2TKMyLY5 
79 | dyzwj7RK98mLwbfaNwIDAQAB'; 
80 | $data = preg_replace('#\s#', '', $data); 
81 | $data = base64_decode($data); 
82 | $data = substr($data, 18+3+1, 141); 
83 | $data = base64_encode($data); 
84 | echo $data;
85 |

That'll get you this:

86 |
    0:d=0  hl=3 l= 137 cons: SEQUENCE 
87 |     3:d=1  hl=3 l= 129 prim:  INTEGER           :AE9E1A795C4129B6713FFA385F753175AF28EBEF9EAD509B36E914CA8156BFEA2B1D3BE4B34DD1D1BEC3AA95EF197B9F18F508FC82854691CB31AD21EBFA711670DE8EA102BE7B5227BB1E4F0F054E13D92259B8C337886CE35F9DE9981D37A97C8786E13DE015810A12D85E1AD9328CC8B639772CF08FB44AF7C98BC1B7DA37
88 |   135:d=1  hl=2 l=   3 prim:  INTEGER           :010001
89 |

ie. you have to go one (1) past the offset from the beginning (18) and the headerlength (3).

90 |
91 | 92 |
93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /rsa/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | RSA Introduction | phpseclib 33 | 34 | 35 | 36 | 37 | 47 | 48 |
49 |
50 |

phpseclib: RSA Feature List

51 | 52 |

Click on any of the following for examples.

53 |
54 |
55 | Download Now 56 |
57 |
58 |
59 |

Supported Private Key Formats

60 | 67 |

Supported Public Key Formats

68 | 73 |
74 |
75 |

Features

76 | 95 |
96 | 97 |
98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /ssh/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | SSH2 Introduction | phpseclib 33 | 34 | 35 | 36 | 37 | 47 | 48 |
49 |
50 |

phpseclib: SSH2 Feature List

51 | 52 |
53 |
54 | Download Now 55 |
56 |
57 |
58 |

phpseclib offers a number of advantages over the alternatives. A list of features is provided below. Click on any of the following for examples.

59 |
60 |
61 |

Authentication

62 | 75 |
76 |
77 |

Features

78 | 105 |
106 | 107 |
108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /sftp/log.txt: -------------------------------------------------------------------------------- 1 | -> NET_SFTP_INIT (0.0003s) 2 | 00000000 00:00:00:03 .... 3 | 4 | <- NET_SFTP_VERSION (0.0605s) 5 | 00000000 00:00:00:03:00:00:00:18:70:6f:73:69:78:2d:72:65 ........posix-re 6 | 00000010 6e:61:6d:65:40:6f:70:65:6e:73:73:68:2e:63:6f:6d name@openssh.com 7 | 00000020 00:00:00:01:31:00:00:00:13:73:74:61:74:76:66:73 ....1....statvfs 8 | 00000030 40:6f:70:65:6e:73:73:68:2e:63:6f:6d:00:00:00:01 @openssh.com.... 9 | 00000040 32:00:00:00:14:66:73:74:61:74:76:66:73:40:6f:70 2....fstatvfs@op 10 | 00000050 65:6e:73:73:68:2e:63:6f:6d:00:00:00:01:32:00:00 enssh.com....2.. 11 | 00000060 00:14:68:61:72:64:6c:69:6e:6b:40:6f:70:65:6e:73 ..hardlink@opens 12 | 00000070 73:68:2e:63:6f:6d:00:00:00:01:31 sh.com....1 13 | 14 | -> NET_SFTP_REALPATH (0.0003s) 15 | 00000000 00:00:00:01:2e ..... 16 | 17 | <- NET_SFTP_NAME (0.0721s) 18 | 00000000 00:00:00:01:00:00:00:01:2f:00:00:00:01:2f:00:00 ......../..../.. 19 | 00000010 00:00 .. 20 | 21 | -> NET_SFTP_OPENDIR (0.0006s) 22 | 00000000 00:00:00:02:2f:2f ....// 23 | 24 | <- NET_SFTP_HANDLE (0.0784s) 25 | 00000000 00:00:00:04:00:00:00:00 ........ 26 | 27 | -> NET_SFTP_READDIR (0.0004s) 28 | 00000000 00:00:00:04:00:00:00:00 ........ 29 | 30 | <- NET_SFTP_NAME (0.0935s) 31 | 00000000 00:00:00:06:00:00:00:07:75:70:6c:6f:61:64:73:00 ........uploads. 32 | 00000010 00:00:3f:64:72:77:78:72:2d:78:72:2d:78:20:20:20 ..?drwxr-xr-x 33 | 00000020 20:32:20:31:30:30:31:20:20:20:20:20:31:30:30:32 2 1001 1002 34 | 00000030 20:20:20:20:20:20:20:20:20:34:30:39:36:20:4d:61 4096 Ma 35 | 00000040 79:20:33:31:20:32:30:3a:35:37:20:75:70:6c:6f:61 y 31 20:57 uploa 36 | 00000050 64:73:00:00:00:0f:00:00:00:00:00:00:10:00:00:00 ds.............. 37 | 00000060 03:e9:00:00:03:ea:00:00:41:ed:4f:c7:dd:ba:4f:c7 ........A.O...O. 38 | 00000070 db:3d:00:00:00:02:2e:2e:00:00:00:3a:64:72:77:78 .=.........:drwx 39 | 00000080 72:2d:78:72:2d:78:20:20:20:20:33:20:30:20:20:20 r-xr-x 3 0 40 | 00000090 20:20:20:20:20:30:20:20:20:20:20:20:20:20:20:20 0 41 | 000000a0 20:20:34:30:39:36:20:4d:61:79:20:33:31:20:32:30 4096 May 31 20 42 | 000000b0 3a:35:37:20:2e:2e:00:00:00:0f:00:00:00:00:00:00 :57 ............ 43 | 000000c0 10:00:00:00:00:00:00:00:00:00:00:00:41:ed:4f:c7 ............A.O. 44 | 000000d0 e1:f8:4f:c7:db:3d:00:00:00:01:2e:00:00:00:39:64 ..O..=........9d 45 | 000000e0 72:77:78:72:2d:78:72:2d:78:20:20:20:20:33:20:30 rwxr-xr-x 3 0 46 | 000000f0 20:20:20:20:20:20:20:20:30:20:20:20:20:20:20:20 0 47 | 00000100 20:20:20:20:20:34:30:39:36:20:4d:61:79:20:33:31 4096 May 31 48 | 00000110 20:32:30:3a:35:37:20:2e:00:00:00:0f:00:00:00:00 20:57 ......... 49 | 00000120 00:00:10:00:00:00:00:00:00:00:00:00:00:00:41:ed ..............A. 50 | 00000130 4f:c7:e1:f8:4f:c7:db:3d:00:00:00:08:2e:70:72:6f O...O..=.....pro 51 | 00000140 66:69:6c:65:00:00:00:40:2d:72:77:2d:72:2d:2d:72 file...@-rw-r--r 52 | 00000150 2d:2d:20:20:20:20:31:20:31:30:31:32:20:20:20:20 -- 1 1012 53 | 00000160 20:31:30:31:33:20:20:20:20:20:20:20:20:20:20:36 1013 6 54 | 00000170 37:35:20:4d:61:79:20:33:31:20:32:30:3a:34:39:20 75 May 31 20:49 55 | 00000180 2e:70:72:6f:66:69:6c:65:00:00:00:0f:00:00:00:00 .profile........ 56 | 00000190 00:00:02:a3:00:00:03:f4:00:00:03:f5:00:00:81:a4 ................ 57 | 000001a0 4f:c7:d9:4d:4f:c7:d9:4d:00:00:00:07:2e:62:61:73 O..MO..M.....bas 58 | 000001b0 68:72:63:00:00:00:3f:2d:72:77:2d:72:2d:2d:72:2d hrc...?-rw-r--r- 59 | 000001c0 2d:20:20:20:20:31:20:31:30:31:32:20:20:20:20:20 - 1 1012 60 | 000001d0 31:30:31:33:20:20:20:20:20:20:20:20:20:33:33:35 1013 335 61 | 000001e0 33:20:4d:61:79:20:33:31:20:32:30:3a:34:39:20:2e 3 May 31 20:49 . 62 | 000001f0 62:61:73:68:72:63:00:00:00:0f:00:00:00:00:00:00 bashrc.......... 63 | 00000200 0d:19:00:00:03:f4:00:00:03:f5:00:00:81:a4:4f:c7 ..............O. 64 | 00000210 d9:4d:4f:c7:d9:4d:00:00:00:0c:2e:62:61:73:68:5f .MO..M.....bash_ 65 | 00000220 6c:6f:67:6f:75:74:00:00:00:44:2d:72:77:2d:72:2d logout...D-rw-r- 66 | 00000230 2d:72:2d:2d:20:20:20:20:31:20:31:30:31:32:20:20 -r-- 1 1012 67 | 00000240 20:20:20:31:30:31:33:20:20:20:20:20:20:20:20:20 1013 68 | 00000250 20:32:32:30:20:4d:61:79:20:33:31:20:32:30:3a:34 220 May 31 20:4 69 | 00000260 39:20:2e:62:61:73:68:5f:6c:6f:67:6f:75:74:00:00 9 .bash_logout.. 70 | 00000270 00:0f:00:00:00:00:00:00:00:dc:00:00:03:f4:00:00 ................ 71 | 00000280 03:f5:00:00:81:a4:4f:c7:d9:4d:4f:c7:d9:4d ......O..MO..M 72 | 73 | -> NET_SFTP_READDIR (0.0004s) 74 | 00000000 00:00:00:04:00:00:00:00 ........ 75 | 76 | <- NET_SFTP_STATUS (0.1173s) 77 | 00000000 00:00:00:01:00:00:00:0b:45:6e:64:20:6f:66:20:66 ........End of f 78 | 00000010 69:6c:65:00:00:00:00 ile.... 79 | 80 | -> NET_SFTP_CLOSE (0.0003s) 81 | 00000000 00:00:00:04:00:00:00:00 ........ 82 | 83 | <- NET_SFTP_STATUS (0.1314s) 84 | 00000000 00:00:00:00:00:00:00:07:53:75:63:63:65:73:73:00 ........Success. 85 | 00000010 00:00:00 ... 86 | -------------------------------------------------------------------------------- /x509/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | X.509 Introduction | phpseclib 6 | 7 | 8 | 9 | 10 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 67 | 68 | 69 | 70 |
71 |
72 |

phpseclib: X.509 Feature List

73 | 74 |
75 |
76 | Download Now 77 |
78 |
79 |
80 |

phpseclib offers a number of advantages over the alternatives. A list of features is provided below. Click on any of the following for examples.

81 |
82 |
83 |

Supported Public Key Algorithms

84 | 87 |

Supported Signature Algorithms

88 | 97 |
98 |
99 |

Features

100 | 144 |
145 | 146 |
147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /ssh/keys.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | SSH2 Special Characters | phpseclib 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 120 | 121 | 135 | 136 |
137 |
138 |

phpseclib: SSH2 Special Characters

139 | 140 |
141 |
142 |
143 |   144 |
145 | 146 |
147 |

SSH2 Special Characters

148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 |
KeyString
Ctrl + C"\x03"
F1"\x1BOP"
F2"\x1BOQ"
F3"\x1BOR"
F4"\x1BOS"
158 |
159 | 160 |
161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /ssh/pty.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | SSH2: PTY Comparisons | phpseclib 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 98 | 99 | 109 | 110 |
111 |
112 |

phpseclib: SSH2: PTY Comparisons

113 | 114 |
115 |
116 |

Examples

117 | 121 |
122 |
123 |

Some commands require a PTY to work correctly with exec(). Examples follow:

124 |

passwd


125 | exec(): 126 |
echo $ssh->exec('passwd');
127 |

Stalls. If you use a callback function or setTimeout() you'll see that it's outputting (current) UNIX password: and waiting for input that can't ever come.

128 | exec() with PTY: 129 |
$ssh->enablePTY(); 
130 | $ssh->exec('passwd'); 
131 | echo $ssh->read('password:'); 
132 | $ssh->write("badpw\n"); 
133 | $ssh->setTimeout(3); 
134 | echo $ssh->read('password unchanged');
135 |

Runs as one might expect. The three second delay is implemented by Linux to protect against brute force attacks (per "man pam_unix").

136 | read() / write(): 137 |
echo $ssh->read('username@username:~$');
138 | $ssh->write("passwd\n");
139 | echo $ssh->read('password:'); 
140 | $ssh->write("badpw\n"); 
141 | $ssh->setTimeout(3); 
142 | echo $ssh->read('password unchanged');
143 |

Pretty much the same output as exec() with PTY.

144 |

top


145 | exec(): 146 |
echo $ssh->exec('top');
147 |

Outputs TERM environment variable not set.

148 | exec() with PTY: 149 |
$ssh->enablePTY();
150 | $ssh->exec('top');
151 | $ssh->setTimeout(5);
152 | $ansi->appendString($ssh->read());
153 | echo $ansi->getScreen();
154 |

See Interactive Shell: ANSI Codes for the output.

155 | read() / write(): 156 |
$ansi->appendString($ssh->read('username@username:~$'));
157 | $ssh->write("top\n");
158 | $ssh->setTimeout(5);
159 | $ansi->appendString($ssh->read());
160 | echo $ansi->getScreen();
161 |

Pretty much the same output as exec() with PTY.

162 |
163 | 164 |
165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | phpseclib: pure PHP implementations of SSH, SFTP, RSA and X.509 6 | 7 | 8 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 52 | 53 |
54 |
55 |

phpseclib 1.0: An Introduction

56 |
57 |
58 |

Pure-PHP implementations of:

59 | 79 |

80 | Download phpseclib 1.0.24 81 |

82 |

83 | Get Support 84 |

85 |
86 |
87 |

Compatibility

88 |

phpseclib is designed to be ultra-compatible. It works on PHP4+ (PHP4, assuming the use of PHP_Compat) and doesn't require any extensions. For purposes of speed, mcrypt is used if it's available as is gmp or bcmath (in that order), but they are not required.

89 |

Interoperability

90 |

phpseclib is designed to be fully interoperable with OpenSSL and other standardized cryptography programs and protocols.

91 |

MIT-Licensed

92 |

phpseclib is licensed with the MIT-license. By virtue of not being copyleft it's less restrictive than the GPL, which in turn, means that it's fully GPL compatible.

93 |

Usage

94 |

This library is written using the same conventions that libraries in the PHP Extension and Application Repository (PEAR) used to be written in (current requirements break PHP4 compatibility). In particular, this library needs to be in your include_path:

95 |
 96 | <?php
 97 | set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
 98 | 
 99 | include('Net/SSH2.php');
100 | ?>
101 |

Other Branches: 2.0, 3.0 and master

102 |

The 2.0 branch has pretty much the exact same API as the 1.0 branch, save for that it is namespaced, uses PHP5-style constructors (thereby avoiding E_DEPRECATED errors) and requires the use of an autoloader. A few examples.

103 |

The 3.0 branch has a vastly different API for public key cryptography. It introduces support for Ed25519 / Ed449, Curve25519, Curve449, ECDSA / ECDH (with support for 66 curves), DSA and DH keys. Symmetric key algorithm support is expanded: ChaCha20, Poly1305 and GCM support are added. SHA3 has been added as well. Documentation can be found at phpseclib.com.

104 |

The master branch has an unstable API that is subject to change. The master branch will eventually turn into 4.0.

105 |
106 | 107 |
108 |
109 |

110 | PEAR Icon PEAR Channel:
phpseclib.sourceforge.net 111 |

112 |

113 | GitHub Icon 114 |

115 |

116 | 117 |

118 |

119 | Support This Project 120 |

121 |
122 | 123 |
124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /x509/2.0/dnprops.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | X.509: Distinguished Property Names | phpseclib 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 155 | 156 | 168 | 169 |
170 |
171 |

phpseclib: X.509: Distinguished Property Names

172 | 173 |
174 |
175 |
176 |   177 |
178 | 179 |
180 |

Valid Distinguished Name Property Names

181 |

The property names are intended to be self-explanatory and are grouped together by they're aliases. They are case insensitive.

182 | 235 |
236 | 237 |
238 | 239 | 240 | 241 | -------------------------------------------------------------------------------- /ssh/auth.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | SSH2 Authentication Examples and Notes | phpseclib 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 45 | 46 | 47 |
48 |
49 |

phpseclib: SSH2 Examples and Notes

50 | 51 |
52 |
53 |
54 |

55 | Login:
56 | 64 |

65 |
66 | 67 |
68 |
69 |
<?php
 70 | include('Net/SSH2.php');
 71 | include('Crypt/RSA.php');
 72 | 
 73 | $ssh = new Net_SSH2('www.domain.tld');
 74 | if (!$ssh->login('username', 'password')) {
 75 |     exit('Login Failed');
 76 | }$key = new Crypt_RSA();
 77 | $key->loadKey(file_get_contents('privatekey'));
 78 | if (!$ssh->login('username', $key)) {
 79 |     exit('Login Failed');
 80 | }$key = new Crypt_RSA();
 81 | $key->setPassword('whatever');
 82 | $key->loadKey(file_get_contents('privatekey'));
 83 | if (!$ssh->login('username', $key)) {
 84 |     exit('Login Failed');
 85 | }$result = $ssh->login('username',
 86 |     array('Password' => 'pass1'),
 87 |     array('Verification code' => 'code1')
 88 | );
 89 | //$result = $ssh->login($username, 'pass1') && !$ssh->login('username', 'code1');
 90 | if (!$result) {
 91 |     exit('Login failed');
 92 | }if (!$ssh->login('username', 'pass1', 'code1')) {
 93 |     exit('Login failed');
 94 | }
 95 | // this does the same thing as the above
 96 | //if (!$ssh->login($username, 'pass1') && !$ssh->login('username', 'code1')) {
 97 | //    exit('Login failed');
 98 | //}
 99 | $ssh->login('username');
100 | $ssh->read('User Name:');
101 | $ssh->write("username\n");
102 | $ssh->read('Password:');
103 | $ssh->write("password\n");
104 | 
105 | echo $ssh->exec('pwd');
106 | echo $ssh->exec('ls -la');
107 | $ssh->setTimeout(1);
108 | $ssh->read();
109 | $ssh->write("ls -la\n");
110 | echo $ssh->read();
111 | ?>
112 |
113 | 114 |
115 |
116 |

On Failure

117 |

If you're absolutely certain that the password / username you've entered are correct it's possible the server isn't using SSH authentication and that what's prompting you for your credentials is the terminal itself. In this scenario you would want to authenticate in the manner demonstrated in the No Authentication example.

118 |
119 |
120 |

Supported Formats

121 |

For a discussion of the supported formats see RSA Feature List

122 |
123 |
124 |

Keyboard-Interactive Authentication

125 |

When doing password authentication phpseclib tries keyboard-interactive if password auth fails. Only after both fail does $ssh->login() return false. The reason for this is that a lot of systems just prompt for the password via keyboard-interactive. So if your server only has one keyboard-interactive prompt using the password authentication method would be sufficient.

126 |

The method utilized in this example is mainly useful when you have multiple keyboard-interactive prompts and need to disambiguate between them. This example utilizes prompt-based disambiguation. One can also distinguish between the various keyboard-interactive prompts via order-based disambiguation. This method is demonstrated in the Multi-Factor example. What'll happen in that example is that password auth will be tried, will presumably fail and then when keyboard-interactive succeeds all subsequent authentications will utilize keyboard-interactive (unless you're trying to auth with an RSA key).

127 |
128 |
129 |

Better Example Wanted

130 |

I would provide a better example but have never had direct access to an SSH server that did authentication in this manner nor do I know how to set one up.

131 |
132 |
133 |
134 | 135 |
136 | 137 | 138 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /ssh/2.0/auth.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | SSH2 Authentication Examples and Notes | phpseclib 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 45 | 46 | 47 |
48 |
49 |

phpseclib: SSH2 Examples and Notes

50 | 51 |
52 |
53 |
54 |

55 | Login:
56 | 64 |

65 |
66 | 67 |
68 |
69 |
<?php
 70 | require __DIR__ . '/vendor/autoload.php';
 71 | 
 72 | use phpseclib\Net\SSH2;
 73 | use phpseclib\Crypt\RSA;
 74 | 
 75 | $ssh = new SSH2('www.domain.tld');
 76 | if (!$ssh->login('username', 'password')) {
 77 |     exit('Login Failed');
 78 | }$key = new RSA();
 79 | $key->loadKey(file_get_contents('privatekey'));
 80 | if (!$ssh->login('username', $key)) {
 81 |     exit('Login Failed');
 82 | }$key = new RSA();
 83 | $key->setPassword('whatever');
 84 | $key->loadKey(file_get_contents('privatekey'));
 85 | if (!$ssh->login('username', $key)) {
 86 |     exit('Login Failed');
 87 | }$result = $ssh->login('username',
 88 |     array('Password' => 'pass1'),
 89 |     array('Verification code' => 'code1')
 90 | );
 91 | //$result = $ssh->login($username, 'pass1') && !$ssh->login('username', 'code1');
 92 | if (!$result) {
 93 |     exit('Login failed');
 94 | }if (!$ssh->login('username', 'pass1', 'code1')) {
 95 |     exit('Login failed');
 96 | }
 97 | // this does the same thing as the above
 98 | //if (!$ssh->login($username, 'pass1') && !$ssh->login('username', 'code1')) {
 99 | //    exit('Login failed');
100 | //}
101 | $ssh->login('username');
102 | $ssh->read('User Name:');
103 | $ssh->write("username\n");
104 | $ssh->read('Password:');
105 | $ssh->write("password\n");
106 | 
107 | echo $ssh->exec('pwd');
108 | echo $ssh->exec('ls -la');
109 | $ssh->setTimeout(1);
110 | $ssh->read();
111 | $ssh->write("ls -la\n");
112 | echo $ssh->read();
113 | ?>
114 |
115 | 116 |
117 |
118 |

On Failure

119 |

If you're absolutely certain that the password / username you've entered are correct it's possible the server isn't using SSH authentication and that what's prompting you for your credentials is the terminal itself. In this scenario you would want to authenticate in the manner demonstrated in the No Authentication example.

120 |
121 |
122 |

Supported Formats

123 |

For a discussion of the supported formats see RSA Feature List

124 |
125 |
126 |

Keyboard-Interactive Authentication

127 |

When doing password authentication phpseclib tries keyboard-interactive if password auth fails. Only after both fail does $ssh->login() return false. The reason for this is that a lot of systems just prompt for the password via keyboard-interactive. So if your server only has one keyboard-interactive prompt using the password authentication method would be sufficient.

128 |

The method utilized in this example is mainly useful when you have multiple keyboard-interactive prompts and need to disambiguate between them. This example utilizes prompt-based disambiguation. One can also distinguish between the various keyboard-interactive prompts via order-based disambiguation. This method is demonstrated in the Multi-Factor example. What'll happen in that example is that password auth will be tried, will presumably fail and then when keyboard-interactive succeeds all subsequent authentications will utilize keyboard-interactive (unless you're trying to auth with an RSA key).

129 |
130 |
131 |

Better Example Wanted

132 |

I would provide a better example but have never had direct access to an SSH server that did authentication in this manner nor do I know how to set one up.

133 |
134 |
135 |
136 | 137 |
138 | 139 | 140 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /x509/dnprops.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | X.509: Distinguished Property Names | phpseclib 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 155 | 156 | 168 | 169 |
170 |
171 |

phpseclib: X.509: Distinguished Property Names

172 | 173 |
174 |
175 |
176 |   177 |
178 | 179 |
180 |

Valid Distinguished Name Property Names

181 |

The property names are intended to be self-explanatory and are grouped together by they're aliases. They are case insensitive.

182 | 235 |
236 | 237 |
238 | 239 | 240 | 241 | -------------------------------------------------------------------------------- /math/intro.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | BigInteger Introduction | phpseclib 33 | 34 | 35 | 36 | 37 | 53 | 54 | 55 |
56 |
57 |

phpseclib: BigInteger Introduction

58 | 59 |
60 |
61 | Download Now 62 |
63 |
64 |
65 |

Operations

66 | 82 |

Bitwise Operations

83 | 94 |

Formating

95 | 102 |
103 |
104 |

Speed Analysis

105 |

The following heat map shows how many seconds Math_BigInteger takes to perform encryption / decryption with a 2048-bit RSA key on an Intel Core i5-3320M CPU @ 2.6GHz under various environments. benchmark.phps was used to generate the heatmap. col*.php are all variations of speed.phps.

106 |

Math_BigInteger automatically picks the fastest settings to use depending on what extensions it has available at its disposal.

107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 |
InternalBCMathInternalBCMathGMP
w/o OpenSSLw/ OpenSSL
PHP 4.419.8404.1252.2270.186
PHP 5.020.3384.0992.3530.193
PHP 5.18.2904.1601.3430.1870.014
PHP 5.27.9443.9951.2100.1770.014
PHP 5.35.7583.2930.7910.2460.017
PHP 5.43.1595.4150.5190.2930.019
PHP 5.53.7194.4590.4850.2270.020
122 |

Internal Engine

123 |

The major limiting factor for the internal implementation is the PHP engine itself. Each successive major version brings with it speed improvements but there's only so much it can do.

124 |

GMP Engine

125 |

GMP, to quote wikipedia, "aims to be faster than any other bignum library", using "highly optimized assembly language code".

126 |

OpenSSL Enhancements

127 |

Only used for powMod(). Converts the exponent and the modulo to an appropriately formatted RSA public key and performs non-padded RSA encryption with that.

128 |
129 | 130 |
131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /js/jquery.treeview.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Treeview 1.5pre - jQuery plugin to hide and show branches of a tree 3 | * 4 | * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ 5 | * http://docs.jquery.com/Plugins/Treeview 6 | * 7 | * Copyright (c) 2007 Jörn Zaefferer 8 | * 9 | * Dual licensed under the MIT and GPL licenses: 10 | * http://www.opensource.org/licenses/mit-license.php 11 | * http://www.gnu.org/licenses/gpl.html 12 | * 13 | * Revision: $Id: jquery.treeview.js 5759 2008-07-01 07:50:28Z joern.zaefferer $ 14 | * 15 | */ 16 | 17 | ;(function($) { 18 | 19 | // TODO rewrite as a widget, removing all the extra plugins 20 | $.extend($.fn, { 21 | swapClass: function(c1, c2) { 22 | var c1Elements = this.filter('.' + c1); 23 | this.filter('.' + c2).removeClass(c2).addClass(c1); 24 | c1Elements.removeClass(c1).addClass(c2); 25 | return this; 26 | }, 27 | replaceClass: function(c1, c2) { 28 | return this.filter('.' + c1).removeClass(c1).addClass(c2).end(); 29 | }, 30 | hoverClass: function(className) { 31 | className = className || "hover"; 32 | return this.hover(function() { 33 | $(this).addClass(className); 34 | }, function() { 35 | $(this).removeClass(className); 36 | }); 37 | }, 38 | heightToggle: function(animated, callback) { 39 | animated ? 40 | this.animate({ height: "toggle" }, animated, callback) : 41 | this.each(function(){ 42 | jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ](); 43 | if(callback) 44 | callback.apply(this, arguments); 45 | }); 46 | }, 47 | heightHide: function(animated, callback) { 48 | if (animated) { 49 | this.animate({ height: "hide" }, animated, callback); 50 | } else { 51 | this.hide(); 52 | if (callback) 53 | this.each(callback); 54 | } 55 | }, 56 | prepareBranches: function(settings) { 57 | if (!settings.prerendered) { 58 | // mark last tree items 59 | this.filter(":last-child:not(ul)").addClass(CLASSES.last); 60 | // collapse whole tree, or only those marked as closed, anyway except those marked as open 61 | this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide(); 62 | } 63 | // return all items with sublists 64 | return this.filter(":has(>ul)"); 65 | }, 66 | applyClasses: function(settings, toggler) { 67 | // TODO use event delegation 68 | this.filter(":has(>ul):not(:has(>a))").find(">span").unbind("click.treeview").bind("click.treeview", function(event) { 69 | // don't handle click events on children, eg. checkboxes 70 | if ( this == event.target ) 71 | toggler.apply($(this).next()); 72 | }).add( $("a", this) ).hoverClass(); 73 | 74 | if (!settings.prerendered) { 75 | // handle closed ones first 76 | this.filter(":has(>ul:hidden)") 77 | .addClass(CLASSES.expandable) 78 | .replaceClass(CLASSES.last, CLASSES.lastExpandable); 79 | 80 | // handle open ones 81 | this.not(":has(>ul:hidden)") 82 | .addClass(CLASSES.collapsable) 83 | .replaceClass(CLASSES.last, CLASSES.lastCollapsable); 84 | 85 | // create hitarea if not present 86 | var hitarea = this.find("div." + CLASSES.hitarea); 87 | if (!hitarea.length) 88 | hitarea = this.prepend("
").find("div." + CLASSES.hitarea); 89 | hitarea.removeClass().addClass(CLASSES.hitarea).each(function() { 90 | var classes = ""; 91 | $.each($(this).parent().attr("class").split(" "), function() { 92 | classes += this + "-hitarea "; 93 | }); 94 | $(this).addClass( classes ); 95 | }) 96 | } 97 | 98 | // apply event to hitarea 99 | this.find("div." + CLASSES.hitarea).click( toggler ); 100 | }, 101 | treeview: function(settings) { 102 | 103 | settings = $.extend({ 104 | cookieId: "treeview" 105 | }, settings); 106 | 107 | if ( settings.toggle ) { 108 | var callback = settings.toggle; 109 | settings.toggle = function() { 110 | return callback.apply($(this).parent()[0], arguments); 111 | }; 112 | } 113 | 114 | // factory for treecontroller 115 | function treeController(tree, control) { 116 | // factory for click handlers 117 | function handler(filter) { 118 | return function() { 119 | // reuse toggle event handler, applying the elements to toggle 120 | // start searching for all hitareas 121 | toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() { 122 | // for plain toggle, no filter is provided, otherwise we need to check the parent element 123 | return filter ? $(this).parent("." + filter).length : true; 124 | }) ); 125 | return false; 126 | }; 127 | } 128 | // click on first element to collapse tree 129 | $("a:eq(0)", control).click( handler(CLASSES.collapsable) ); 130 | // click on second to expand tree 131 | $("a:eq(1)", control).click( handler(CLASSES.expandable) ); 132 | // click on third to toggle tree 133 | $("a:eq(2)", control).click( handler() ); 134 | } 135 | 136 | // handle toggle event 137 | function toggler() { 138 | $(this) 139 | .parent() 140 | // swap classes for hitarea 141 | .find(">.hitarea") 142 | .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) 143 | .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ) 144 | .end() 145 | // swap classes for parent li 146 | .swapClass( CLASSES.collapsable, CLASSES.expandable ) 147 | .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) 148 | // find child lists 149 | .find( ">ul" ) 150 | // toggle them 151 | .heightToggle( settings.animated, settings.toggle ); 152 | if ( settings.unique ) { 153 | $(this).parent() 154 | .siblings() 155 | // swap classes for hitarea 156 | .find(">.hitarea") 157 | .replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) 158 | .replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ) 159 | .end() 160 | .replaceClass( CLASSES.collapsable, CLASSES.expandable ) 161 | .replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) 162 | .find( ">ul" ) 163 | .heightHide( settings.animated, settings.toggle ); 164 | } 165 | } 166 | this.data("toggler", toggler); 167 | 168 | function serialize() { 169 | function binary(arg) { 170 | return arg ? 1 : 0; 171 | } 172 | var data = []; 173 | branches.each(function(i, e) { 174 | data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0; 175 | }); 176 | $.cookie(settings.cookieId, data.join(""), settings.cookieOptions ); 177 | } 178 | 179 | function deserialize() { 180 | var stored = $.cookie(settings.cookieId); 181 | if ( stored ) { 182 | var data = stored.split(""); 183 | branches.each(function(i, e) { 184 | $(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ](); 185 | }); 186 | } 187 | } 188 | 189 | // add treeview class to activate styles 190 | this.addClass("treeview"); 191 | 192 | // prepare branches and find all tree items with child lists 193 | var branches = this.find("li").prepareBranches(settings); 194 | 195 | switch(settings.persist) { 196 | case "cookie": 197 | var toggleCallback = settings.toggle; 198 | settings.toggle = function() { 199 | serialize(); 200 | if (toggleCallback) { 201 | toggleCallback.apply(this, arguments); 202 | } 203 | }; 204 | deserialize(); 205 | break; 206 | case "location": 207 | var current = this.find("a").filter(function() { 208 | return this.href.toLowerCase() == location.href.toLowerCase(); 209 | }); 210 | if ( current.length ) { 211 | // TODO update the open/closed classes 212 | var items = current.addClass("selected").parents("ul, li").add( current.next() ).show(); 213 | if (settings.prerendered) { 214 | // if prerendered is on, replicate the basic class swapping 215 | items.filter("li") 216 | .swapClass( CLASSES.collapsable, CLASSES.expandable ) 217 | .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) 218 | .find(">.hitarea") 219 | .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) 220 | .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ); 221 | } 222 | } 223 | break; 224 | } 225 | 226 | branches.applyClasses(settings, toggler); 227 | 228 | // if control option is set, create the treecontroller and show it 229 | if ( settings.control ) { 230 | treeController(this, settings.control); 231 | $(settings.control).show(); 232 | } 233 | 234 | return this; 235 | } 236 | }); 237 | 238 | // classes used by the plugin 239 | // need to be styled via external stylesheet, see first example 240 | $.treeview = {}; 241 | var CLASSES = ($.treeview.classes = { 242 | open: "open", 243 | closed: "closed", 244 | expandable: "expandable", 245 | expandableHitarea: "expandable-hitarea", 246 | lastExpandableHitarea: "lastExpandable-hitarea", 247 | collapsable: "collapsable", 248 | collapsableHitarea: "collapsable-hitarea", 249 | lastCollapsableHitarea: "lastCollapsable-hitarea", 250 | lastCollapsable: "lastCollapsable", 251 | lastExpandable: "lastExpandable", 252 | last: "last", 253 | hitarea: "hitarea" 254 | }); 255 | 256 | })(jQuery); -------------------------------------------------------------------------------- /x509/decoder.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 21 | X.509 Decoder | phpseclib 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 121 | 122 | 135 | 136 |
137 |
138 |

phpseclib: X.509 Decoder

139 | 140 |
141 |
142 |
143 |
144 |

The associative array returned by this page corresponds to the ASN.1 description of X.509 certificates.

145 |

Also, note that subjectPublicKey will not be decodable by OpenSSL as OpenSSL's rsautl function expects the public key to not only contain subjectPublicKey but also everything else in subjectPublicKeyInfo. ie. OpenSSL requires the public key explicitly identify it's using. Crypt_RSA can handle this format though and convert it if that's needed.

146 |

See ASN.1 Parser as well.

147 |
148 |
149 | 150 |
151 |
152 | 155 |
156 | Copy / paste certificate:
157 |
176 | Upload certificate:
177 |
178 | 179 |
180 | $value) { 190 | $key = (string) $key; 191 | switch ($key) { 192 | case 'subjectPublicKey': 193 | $open = '
';
194 |                     $close = '
'; 195 | break; 196 | case 'signature': 197 | $open = '
'; 198 | $close = '
'; 199 | break; 200 | default: 201 | $open = $close = ''; 202 | } 203 | $result.= '
  • ' . $key . '' . (is_array($value) ? array2html($value, false) : '
    • ' . $open . htmlspecialchars($value) . $close . '
    ') . '
  • '; 204 | } 205 | $start = $start ? ' class="printr"' : ''; 206 | return '' . $result . ''; 207 | } 208 | 209 | $x509 = new File_X509(); 210 | $cert = $x509->loadX509($cert); 211 | 212 | //echo '
    Subject: ' . $x509->getDN(true) . '
    '; 213 | //echo 'Issuer: ' . $x509->getIssuerDN(true) . '
    '; 214 | echo '
    Subject' . $x509->getDN(true) . '
    Issuer' . $x509->getIssuerDN(true) . '
    '; 215 | ?> 216 | $cert 217 | 223 |
    224 |
    225 | 226 |
    227 | 228 | 229 | -------------------------------------------------------------------------------- /ssh/compare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | libssh2 vs phpseclib | phpseclib 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 57 | 58 | 59 |
    60 |
    61 |

    phpseclib: libssh2 vs phpseclib

    62 | 63 |
    64 |
    65 | Download phpseclib 66 |
    67 |
    68 | 79 |
    80 |

    Whether or not the API is better to libssh2 is debatable. This comparison looks at more objective criteria.

    81 |

    Portability

    82 |

    phpseclib is designed to be ultra-portable, even to the point of working on PHP4. Not a single extension is required, either (although if they're available they'll be used, for speed).

    83 |

    libssh2, in contrast... if you're on a shared host that doesn't have it installed (and most don't) you're S.O.L. And even if your server is running on a dedicated box it's still one extra step you have to do to install it. As if migrating to a new server wasn't enough of a challenge do you really want to compound the challenge by adding an additional server dependency like libssh2?

    84 |

    Speed

    85 |

    The following table shows how long, in seconds, it took to transfer a 1mb file via phpseclib and libssh2 to localhost and to a remote host.

    86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
    Uploadremote hostlibssh213.0037
    phpseclib11.1086
    localhostlibssh21.1250
    phpseclib0.3380
    Downloadremote hostlibssh24.8302
    phpseclib2.4311
    localhostlibssh20.7680
    phpseclib0.4400
    128 |

    This test was conducted on an Intel Core i5-3320M CPU @ 2.6GHz running Windows 7 64-bit and PHP 5.4.19 and libssh 0.12 and the latest Git version of phpseclib with the gmp and mcrypt extensions installed.

    129 |

    The connection to the remote host was done with a 1MB upload speed. Here's the speedtest.net results:

    130 |

    speed test

    131 |

    The code used to conduct these tests is at upload.phps and download.phps.

    132 |

    The motivation for doing a separate test for remote hosts and localhosts was to compare the speeds with different bottlenecks. ie. with the remote host the bandwidth is the bottleneck. With localhost bandwidth is eliminated as a bottleneck. This shows that phpseclib performs better under a multitude of conditions.

    133 |

    Public Key Support

    134 |

    How you do it with libssh2:

    135 |
    <?php
    136 | $ssh = ssh2_connect('domain.tld');
    137 | ssh2_auth_pubkey_file($ssh, 'username', '/home/ubuntu/pubkey', '/home/ubuntu/privkey'/*, 'password'*/);
    138 | 
    139 | $stream = ssh2_exec($ssh, 'ls -la');
    140 | echo stream_get_contents($stream);
    141 |

    Both have to be of the right format too. If you didn't use ssh-keygen to generate your keys good luck in converting them.

    142 |
    <?php
    143 | include('Net/SSH2.php');
    144 | include('Crypt/RSA.php');
    145 | 
    146 | $rsa = new Crypt_RSA();
    147 | //$rsa->setPassword('password');
    148 | $rsa->loadKey('...');
    149 | 
    150 | $ssh = new Net_SSH2('domain.tld');
    151 | $ssh->login('username', $rsa);
    152 | 
    153 | echo $ssh->exec('ls -la');
    154 |

    Ignoring the API for the time being there are a few clear ways phpseclib comes out on top here:

    155 |
      156 |
    • phpseclib takes in strings - not file paths. If you want to do a file you can do file_get_contents.
    • 157 |
    • phpseclib doesn't require a public key. Most private key formats have the public key embedded within them. And if they don't... phpseclib supports that too.
    • 158 |
    • phpseclib can take in pretty much any standardized format, from PKCS#1 formatted keys, to PuTTY keys, to XML Signature keys
    • 159 |
    160 |

    Diagnosing Problems

    161 |

    Why didn't top or sudo work? With phpseclib you can get logs. They look like this:

    162 |

    http://phpseclib.sourceforge.net/ssh/log.txt

    163 |

    You can also do print_r($ssh->getErrors()) or echo $ssh->getLastError()

    164 |

    Changing Directories

    165 |

    I don't see any cd or chdir functions at http://php.net/ssh2. phpseclib, however, has it - Net_SFTP::chdir(...)

    166 |

    Interactive Shell

    167 |

    Let's try to do sudo on the remote system.

    168 |

    With phpseclib: examples.html#sudo

    169 |

    With libssh2? I have no clue. My best guess (doesn't work):

    170 |
    <?php
    171 | $ssh = ssh2_connect('domain.tld'); 
    172 | ssh2_auth_password($ssh, 'username', 'password');
    173 | 
    174 | $shell = ssh2_shell($ssh);
    175 | echo fread($shell, 1024*1024);
    176 | fwrite($shell, "sudo ls -la\n");
    177 | $output = fread($shell, 1024*1024);
    178 | echo $output;
    179 | if (preg_match('#[pP]assword[^:]*:#', $output)) {
    180 |     fwrite($shell, "password\n");
    181 | }
    182 | echo fread($shell, 1024*1024);
    183 |

    It is additionally unclear how to get top working with libssh2 but it works perfectly fine with phpseclib: examples.html#top.

    184 |
    185 | 186 |
    187 | 188 | 189 | 190 | -------------------------------------------------------------------------------- /css/960.css: -------------------------------------------------------------------------------- 1 | /* 2 | 960 Grid System ~ Core CSS. 3 | Learn more ~ http://960.gs/ 4 | 5 | Licensed under GPL and MIT. 6 | */ 7 | 8 | /* 9 | Forces backgrounds to span full width, 10 | even if there is horizontal scrolling. 11 | Increase this if your layout is wider. 12 | 13 | Note: IE6 works fine without this fix. 14 | */ 15 | 16 | body { 17 | min-width: 960px; 18 | } 19 | 20 | /* `Container 21 | ----------------------------------------------------------------------------------------------------*/ 22 | 23 | .container_12, 24 | .container_16 { 25 | margin-left: auto; 26 | margin-right: auto; 27 | width: 960px; 28 | } 29 | 30 | /* `Grid >> Global 31 | ----------------------------------------------------------------------------------------------------*/ 32 | 33 | .grid_1, 34 | .grid_2, 35 | .grid_3, 36 | .grid_4, 37 | .grid_5, 38 | .grid_6, 39 | .grid_7, 40 | .grid_8, 41 | .grid_9, 42 | .grid_10, 43 | .grid_11, 44 | .grid_12, 45 | .grid_13, 46 | .grid_14, 47 | .grid_15, 48 | .grid_16 { 49 | display: inline; 50 | float: left; 51 | margin-left: 10px; 52 | margin-right: 10px; 53 | } 54 | 55 | .push_1, .pull_1, 56 | .push_2, .pull_2, 57 | .push_3, .pull_3, 58 | .push_4, .pull_4, 59 | .push_5, .pull_5, 60 | .push_6, .pull_6, 61 | .push_7, .pull_7, 62 | .push_8, .pull_8, 63 | .push_9, .pull_9, 64 | .push_10, .pull_10, 65 | .push_11, .pull_11, 66 | .push_12, .pull_12, 67 | .push_13, .pull_13, 68 | .push_14, .pull_14, 69 | .push_15, .pull_15 { 70 | position: relative; 71 | } 72 | 73 | .container_12 .grid_3, 74 | .container_16 .grid_4 { 75 | width: 220px; 76 | } 77 | 78 | .container_12 .grid_6, 79 | .container_16 .grid_8 { 80 | width: 460px; 81 | } 82 | 83 | .container_12 .grid_9, 84 | .container_16 .grid_12 { 85 | width: 700px; 86 | } 87 | 88 | .container_12 .grid_12, 89 | .container_16 .grid_16 { 90 | width: 940px; 91 | } 92 | 93 | /* `Grid >> Children (Alpha ~ First, Omega ~ Last) 94 | ----------------------------------------------------------------------------------------------------*/ 95 | 96 | .alpha { 97 | margin-left: 0; 98 | } 99 | 100 | .omega { 101 | margin-right: 0; 102 | } 103 | 104 | /* `Grid >> 12 Columns 105 | ----------------------------------------------------------------------------------------------------*/ 106 | 107 | .container_12 .grid_1 { 108 | width: 60px; 109 | } 110 | 111 | .container_12 .grid_2 { 112 | width: 140px; 113 | } 114 | 115 | .container_12 .grid_4 { 116 | width: 300px; 117 | } 118 | 119 | .container_12 .grid_5 { 120 | width: 380px; 121 | } 122 | 123 | .container_12 .grid_7 { 124 | width: 540px; 125 | } 126 | 127 | .container_12 .grid_8 { 128 | width: 620px; 129 | } 130 | 131 | .container_12 .grid_10 { 132 | width: 780px; 133 | } 134 | 135 | .container_12 .grid_11 { 136 | width: 860px; 137 | } 138 | 139 | /* `Grid >> 16 Columns 140 | ----------------------------------------------------------------------------------------------------*/ 141 | 142 | .container_16 .grid_1 { 143 | width: 40px; 144 | } 145 | 146 | .container_16 .grid_2 { 147 | width: 100px; 148 | } 149 | 150 | .container_16 .grid_3 { 151 | width: 160px; 152 | } 153 | 154 | .container_16 .grid_5 { 155 | width: 280px; 156 | } 157 | 158 | .container_16 .grid_6 { 159 | width: 340px; 160 | } 161 | 162 | .container_16 .grid_7 { 163 | width: 400px; 164 | } 165 | 166 | .container_16 .grid_9 { 167 | width: 520px; 168 | } 169 | 170 | .container_16 .grid_10 { 171 | width: 580px; 172 | } 173 | 174 | .container_16 .grid_11 { 175 | width: 640px; 176 | } 177 | 178 | .container_16 .grid_13 { 179 | width: 760px; 180 | } 181 | 182 | .container_16 .grid_14 { 183 | width: 820px; 184 | } 185 | 186 | .container_16 .grid_15 { 187 | width: 880px; 188 | } 189 | 190 | /* `Prefix Extra Space >> Global 191 | ----------------------------------------------------------------------------------------------------*/ 192 | 193 | .container_12 .prefix_3, 194 | .container_16 .prefix_4 { 195 | padding-left: 240px; 196 | } 197 | 198 | .container_12 .prefix_6, 199 | .container_16 .prefix_8 { 200 | padding-left: 480px; 201 | } 202 | 203 | .container_12 .prefix_9, 204 | .container_16 .prefix_12 { 205 | padding-left: 720px; 206 | } 207 | 208 | /* `Prefix Extra Space >> 12 Columns 209 | ----------------------------------------------------------------------------------------------------*/ 210 | 211 | .container_12 .prefix_1 { 212 | padding-left: 80px; 213 | } 214 | 215 | .container_12 .prefix_2 { 216 | padding-left: 160px; 217 | } 218 | 219 | .container_12 .prefix_4 { 220 | padding-left: 320px; 221 | } 222 | 223 | .container_12 .prefix_5 { 224 | padding-left: 400px; 225 | } 226 | 227 | .container_12 .prefix_7 { 228 | padding-left: 560px; 229 | } 230 | 231 | .container_12 .prefix_8 { 232 | padding-left: 640px; 233 | } 234 | 235 | .container_12 .prefix_10 { 236 | padding-left: 800px; 237 | } 238 | 239 | .container_12 .prefix_11 { 240 | padding-left: 880px; 241 | } 242 | 243 | /* `Prefix Extra Space >> 16 Columns 244 | ----------------------------------------------------------------------------------------------------*/ 245 | 246 | .container_16 .prefix_1 { 247 | padding-left: 60px; 248 | } 249 | 250 | .container_16 .prefix_2 { 251 | padding-left: 120px; 252 | } 253 | 254 | .container_16 .prefix_3 { 255 | padding-left: 180px; 256 | } 257 | 258 | .container_16 .prefix_5 { 259 | padding-left: 300px; 260 | } 261 | 262 | .container_16 .prefix_6 { 263 | padding-left: 360px; 264 | } 265 | 266 | .container_16 .prefix_7 { 267 | padding-left: 420px; 268 | } 269 | 270 | .container_16 .prefix_9 { 271 | padding-left: 540px; 272 | } 273 | 274 | .container_16 .prefix_10 { 275 | padding-left: 600px; 276 | } 277 | 278 | .container_16 .prefix_11 { 279 | padding-left: 660px; 280 | } 281 | 282 | .container_16 .prefix_13 { 283 | padding-left: 780px; 284 | } 285 | 286 | .container_16 .prefix_14 { 287 | padding-left: 840px; 288 | } 289 | 290 | .container_16 .prefix_15 { 291 | padding-left: 900px; 292 | } 293 | 294 | /* `Suffix Extra Space >> Global 295 | ----------------------------------------------------------------------------------------------------*/ 296 | 297 | .container_12 .suffix_3, 298 | .container_16 .suffix_4 { 299 | padding-right: 240px; 300 | } 301 | 302 | .container_12 .suffix_6, 303 | .container_16 .suffix_8 { 304 | padding-right: 480px; 305 | } 306 | 307 | .container_12 .suffix_9, 308 | .container_16 .suffix_12 { 309 | padding-right: 720px; 310 | } 311 | 312 | /* `Suffix Extra Space >> 12 Columns 313 | ----------------------------------------------------------------------------------------------------*/ 314 | 315 | .container_12 .suffix_1 { 316 | padding-right: 80px; 317 | } 318 | 319 | .container_12 .suffix_2 { 320 | padding-right: 160px; 321 | } 322 | 323 | .container_12 .suffix_4 { 324 | padding-right: 320px; 325 | } 326 | 327 | .container_12 .suffix_5 { 328 | padding-right: 400px; 329 | } 330 | 331 | .container_12 .suffix_7 { 332 | padding-right: 560px; 333 | } 334 | 335 | .container_12 .suffix_8 { 336 | padding-right: 640px; 337 | } 338 | 339 | .container_12 .suffix_10 { 340 | padding-right: 800px; 341 | } 342 | 343 | .container_12 .suffix_11 { 344 | padding-right: 880px; 345 | } 346 | 347 | /* `Suffix Extra Space >> 16 Columns 348 | ----------------------------------------------------------------------------------------------------*/ 349 | 350 | .container_16 .suffix_1 { 351 | padding-right: 60px; 352 | } 353 | 354 | .container_16 .suffix_2 { 355 | padding-right: 120px; 356 | } 357 | 358 | .container_16 .suffix_3 { 359 | padding-right: 180px; 360 | } 361 | 362 | .container_16 .suffix_5 { 363 | padding-right: 300px; 364 | } 365 | 366 | .container_16 .suffix_6 { 367 | padding-right: 360px; 368 | } 369 | 370 | .container_16 .suffix_7 { 371 | padding-right: 420px; 372 | } 373 | 374 | .container_16 .suffix_9 { 375 | padding-right: 540px; 376 | } 377 | 378 | .container_16 .suffix_10 { 379 | padding-right: 600px; 380 | } 381 | 382 | .container_16 .suffix_11 { 383 | padding-right: 660px; 384 | } 385 | 386 | .container_16 .suffix_13 { 387 | padding-right: 780px; 388 | } 389 | 390 | .container_16 .suffix_14 { 391 | padding-right: 840px; 392 | } 393 | 394 | .container_16 .suffix_15 { 395 | padding-right: 900px; 396 | } 397 | 398 | /* `Push Space >> Global 399 | ----------------------------------------------------------------------------------------------------*/ 400 | 401 | .container_12 .push_3, 402 | .container_16 .push_4 { 403 | left: 240px; 404 | } 405 | 406 | .container_12 .push_6, 407 | .container_16 .push_8 { 408 | left: 480px; 409 | } 410 | 411 | .container_12 .push_9, 412 | .container_16 .push_12 { 413 | left: 720px; 414 | } 415 | 416 | /* `Push Space >> 12 Columns 417 | ----------------------------------------------------------------------------------------------------*/ 418 | 419 | .container_12 .push_1 { 420 | left: 80px; 421 | } 422 | 423 | .container_12 .push_2 { 424 | left: 160px; 425 | } 426 | 427 | .container_12 .push_4 { 428 | left: 320px; 429 | } 430 | 431 | .container_12 .push_5 { 432 | left: 400px; 433 | } 434 | 435 | .container_12 .push_7 { 436 | left: 560px; 437 | } 438 | 439 | .container_12 .push_8 { 440 | left: 640px; 441 | } 442 | 443 | .container_12 .push_10 { 444 | left: 800px; 445 | } 446 | 447 | .container_12 .push_11 { 448 | left: 880px; 449 | } 450 | 451 | /* `Push Space >> 16 Columns 452 | ----------------------------------------------------------------------------------------------------*/ 453 | 454 | .container_16 .push_1 { 455 | left: 60px; 456 | } 457 | 458 | .container_16 .push_2 { 459 | left: 120px; 460 | } 461 | 462 | .container_16 .push_3 { 463 | left: 180px; 464 | } 465 | 466 | .container_16 .push_5 { 467 | left: 300px; 468 | } 469 | 470 | .container_16 .push_6 { 471 | left: 360px; 472 | } 473 | 474 | .container_16 .push_7 { 475 | left: 420px; 476 | } 477 | 478 | .container_16 .push_9 { 479 | left: 540px; 480 | } 481 | 482 | .container_16 .push_10 { 483 | left: 600px; 484 | } 485 | 486 | .container_16 .push_11 { 487 | left: 660px; 488 | } 489 | 490 | .container_16 .push_13 { 491 | left: 780px; 492 | } 493 | 494 | .container_16 .push_14 { 495 | left: 840px; 496 | } 497 | 498 | .container_16 .push_15 { 499 | left: 900px; 500 | } 501 | 502 | /* `Pull Space >> Global 503 | ----------------------------------------------------------------------------------------------------*/ 504 | 505 | .container_12 .pull_3, 506 | .container_16 .pull_4 { 507 | left: -240px; 508 | } 509 | 510 | .container_12 .pull_6, 511 | .container_16 .pull_8 { 512 | left: -480px; 513 | } 514 | 515 | .container_12 .pull_9, 516 | .container_16 .pull_12 { 517 | left: -720px; 518 | } 519 | 520 | /* `Pull Space >> 12 Columns 521 | ----------------------------------------------------------------------------------------------------*/ 522 | 523 | .container_12 .pull_1 { 524 | left: -80px; 525 | } 526 | 527 | .container_12 .pull_2 { 528 | left: -160px; 529 | } 530 | 531 | .container_12 .pull_4 { 532 | left: -320px; 533 | } 534 | 535 | .container_12 .pull_5 { 536 | left: -400px; 537 | } 538 | 539 | .container_12 .pull_7 { 540 | left: -560px; 541 | } 542 | 543 | .container_12 .pull_8 { 544 | left: -640px; 545 | } 546 | 547 | .container_12 .pull_10 { 548 | left: -800px; 549 | } 550 | 551 | .container_12 .pull_11 { 552 | left: -880px; 553 | } 554 | 555 | /* `Pull Space >> 16 Columns 556 | ----------------------------------------------------------------------------------------------------*/ 557 | 558 | .container_16 .pull_1 { 559 | left: -60px; 560 | } 561 | 562 | .container_16 .pull_2 { 563 | left: -120px; 564 | } 565 | 566 | .container_16 .pull_3 { 567 | left: -180px; 568 | } 569 | 570 | .container_16 .pull_5 { 571 | left: -300px; 572 | } 573 | 574 | .container_16 .pull_6 { 575 | left: -360px; 576 | } 577 | 578 | .container_16 .pull_7 { 579 | left: -420px; 580 | } 581 | 582 | .container_16 .pull_9 { 583 | left: -540px; 584 | } 585 | 586 | .container_16 .pull_10 { 587 | left: -600px; 588 | } 589 | 590 | .container_16 .pull_11 { 591 | left: -660px; 592 | } 593 | 594 | .container_16 .pull_13 { 595 | left: -780px; 596 | } 597 | 598 | .container_16 .pull_14 { 599 | left: -840px; 600 | } 601 | 602 | .container_16 .pull_15 { 603 | left: -900px; 604 | } 605 | 606 | /* `Clear Floated Elements 607 | ----------------------------------------------------------------------------------------------------*/ 608 | 609 | /* http://sonspring.com/journal/clearing-floats */ 610 | 611 | .clear { 612 | clear: both; 613 | display: block; 614 | overflow: hidden; 615 | visibility: hidden; 616 | width: 0; 617 | height: 0; 618 | } 619 | 620 | /* http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified */ 621 | 622 | .clearfix:before, 623 | .clearfix:after, 624 | .container_12:before, 625 | .container_12:after, 626 | .container_16:before, 627 | .container_16:after { 628 | content: '.'; 629 | display: block; 630 | overflow: hidden; 631 | visibility: hidden; 632 | font-size: 0; 633 | line-height: 0; 634 | width: 0; 635 | height: 0; 636 | } 637 | 638 | .clearfix:after, 639 | .container_12:after, 640 | .container_16:after { 641 | clear: both; 642 | } 643 | 644 | /* 645 | The following zoom:1 rule is specifically for IE6 + IE7. 646 | Move to separate stylesheet if invalid CSS is a problem. 647 | */ 648 | 649 | .clearfix, 650 | .container_12, 651 | .container_16 { 652 | zoom: 1; 653 | } -------------------------------------------------------------------------------- /sftp/2.0/examples.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 20 | SFTP Examples and Notes | phpseclib 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 43 | 44 | 56 | 57 | 58 |
    59 |
    60 |

    phpseclib: SFTP Examples and Notes

    61 | 62 |
    63 |
    64 |
    65 |

    66 | Action:
    67 | 76 |

    77 |

    78 | 79 | 80 |

    81 |
    82 | 83 |
    84 |
    85 |
    <?php
     86 | require __DIR__ . '/vendor/autoload.php';
     87 | 
     88 | use phpseclib\Net\SFTP;
     89 | 
     90 | define('NET_SFTP_LOGGING', SFTP::LOG_COMPLEX);
     91 | 
     92 | $sftp = new SFTP('www.domain.tld');
     93 | if (!$sftp->login('username', 'password')) {
     94 |     exit('Login Failed');
     95 | }
     96 | 
     97 | // puts a three-byte file named filename.remote on the SFTP server
     98 | $sftp->put('filename.remote', 'xxx');
     99 | // puts an x-byte file named filename.remote on the SFTP server,
    100 | // where x is the size of filename.local
    101 | $sftp->put('filename.remote', 'filename.local', SFTP::SOURCE_LOCAL_FILE);// outputs the contents of filename.remote to the screen
    102 | echo $sftp->get('filename.remote');
    103 | // copies filename.remote to filename.local from the SFTP server
    104 | $sftp->get('filename.remote', 'filename.local');$sftp->mkdir('test'); // create directory 'test'
    105 | $sftp->chdir('test'); // open directory 'test'
    106 | echo $sftp->pwd(); // show that we're in the 'test' directory
    107 | $sftp->chdir('..'); // go back to the parent directory
    108 | $sftp->rmdir('test'); // delete the directory
    109 | // if the directory had files in it we'd need to do a recursive delete
    110 | //$sftp->delete('test');
    111 | print_r($sftp->nlist()); // == $sftp->nlist('.')
    112 | print_r($sftp->rawlist()); // == $sftp->rawlist('.')
    113 | $sftp->chmod(0777, 'filename.remote');
    114 | //$sftp->chmod(0777, 'dirname.remote', true); // recursively change permissions on a directory
    115 | // has the same syntax as http://php.net/touch
    116 | $sftp->touch('filename.remote');
    117 | $sftp->chown('filename.remote', $uid);
    118 | //$sftp->chown('filename.remote', $uid, true); // recursively change the owner
    119 | $sftp->chgrp('filename.remote', $gid);
    120 | //$sftp->chgrp('filename.remote', $gid, true); // recursively change the group
    121 | $sftp->truncate('filename.remote', $size);
    122 | echo $sftp->size('filename.remote');
    123 | print_r($sftp->stat('filename.remote'));
    124 | print_r($sftp->lstat('filename.remote'));$sftp->delete('filename.remote'); // deletes directories recursively
    125 | // non-recursive delete
    126 | $sftp->delete('dirname.remote', false);
    127 | $sftp->rename('filename.remote', 'newname.remote');
    128 | 
    129 | echo $sftp->getSFTPLog();
    130 | ?>
    131 |
    132 | 133 |
    134 |
    135 |

    Output of nlist() and rawlist()

    136 | $sftp->nlist(): 137 |
    • 0
      • uploads
    • 1
      • ..
    • 2
      • .
    • 3
      • .profile
    • 4
      • .bashrc
    • 5
      • .bash_logout
    138 | $sftp->rawlist(): 139 |
    • uploads
      • size
        • 4096
      • uid
        • 1001
      • gid
        • 1002
      • permissions
        • 16877
      • atime
        • 1338498490
      • mtime
        • 1338497853
      • type
        • 2
    • ..
      • size
        • 4096
      • uid
        • 0
      • gid
        • 0
      • permissions
        • 16877
      • atime
        • 1338499576
      • mtime
        • 1338497853
      • type
        • 2
    • .
      • size
        • 4096
      • uid
        • 0
      • gid
        • 0
      • permissions
        • 16877
      • atime
        • 1338499576
      • mtime
        • 1338497853
      • type
        • 2
    • .profile
      • size
        • 675
      • uid
        • 1012
      • gid
        • 1013
      • permissions
        • 33188
      • atime
        • 1338497357
      • mtime
        • 1338497357
      • type
        • 1
    • bashrc
      • size
        • 3353
      • uid
        • 1012
      • gid
        • 1013
      • permissions
        • 33188
      • atime
        • 1338497357
      • mtime
        • 1338497357
      • type
        • 1
    • .bash_lougout
      • size
        • 270
      • uid
        • 1012
      • gid
        • 1013
      • permissions
        • 33188
      • atime
        • 1338497357
      • mtime
        • 1338497357
      • type
        • 1
    140 | The type index corresponds to one of the following named constants: 141 |
      142 |
    • NET_SFTP_TYPE_REGULAR
    • 143 |
    • NET_SFTP_TYPE_DIRECTORY
    • 144 |
    • NET_SFTP_TYPE_SYMLINK
    • 145 |
    • NET_SFTP_TYPE_SPECIAL
    • 146 |
    147 |
    148 |
    149 |

    stat() vs. lstat() vs. size()

    150 |

    stat() and lstat() return associative arrays with misc information about the files. lstat() and stat() are identical with the caveat that when the file in question is a symbolic link the information returned refers to the link itself and not the file (or directory) being linked to.

    151 |

    size() returns the 'size' index of the associative array returned by lstat()

    152 |
    153 |
    154 |

    Uploading files

    155 |

    The function definition for put() is as follows:

    156 |
    function put($remote_file, $data, $mode = SFTP::SOURCE_STRING, $start = -1, $local_start = -1)
    157 |

    Uploading strings vs. files

    158 |

    $sftp->put('filename.remote', 'filename.local') creates filename.remote on the remote server with 'filename.local' as the contents.

    159 |

    $sftp->put('filename.remote', 'xxx', SFTP::SOURCE_LOCAL_FILE) creates filename.remote on the remote server such that the contents of it and filename.local match. ie. with SFTP::SOURCE_LOCAL_FILE it uploads a file and without it it uploads a string.

    160 |

    Resuming transfers

    161 |

    $sftp->put('filename.remote', 'xxx', SFTP::RESUME) will append 'xxx' to filename.remote.

    162 |

    $sftp->put('filename.remote', 'filename.local', SFTP::SOURCE_LOCAL_FILE | SFTP::RESUME_START) will append filename.remote to filename.local.

    163 |

    $sftp->put('filename.remote', 'filename.local', SFTP::SOURCE_LOCAL_FILE | SFTP::RESUME) will append all but the first $sftp->size('filename.remote') bytes of filename.local to filename.remote. The idea being that if your transfer is interupted you can restart it.

    164 |

    Positional control

    165 |

    $start and $local_start give you more fine grained control over this process and take precident over SFTP::RESUME when they're non-negative. ie. $start could let you write at the end of a file (like SFTP::RESUME) or in the middle of one. $local_start could let you start your reading from the end of a file (like SFTP::RESUME_START) or in the middle of one.

    166 |
    167 |
    168 |

    Downloading files

    169 |

    The function definition for get() is as follows:

    170 |
    function get($remote_file, $local_file = false, $offset = 0, $length = -1)
    171 |

    Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the operation.

    172 |
    173 |
    174 |
    175 | 176 |
    177 | 178 | 179 | 190 | 191 | 192 | --------------------------------------------------------------------------------