Skip to content

ariadata/WinSCP-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinSCP PHP Library

A simple and powerful PHP library for working with WinSCP password encryption and session management.

🚀 Features

  • Password Encryption/Decryption: Encrypt and decrypt passwords using WinSCP's proprietary algorithm
  • Format Conversion: Convert between JSON and WinSCP INI formats
  • Session Management: Handle WinSCP session configurations with support for categories and nested structures
  • Production Ready: Tested and optimized for production environments

📦 Installation

Simply download the WinSCP.php file and include it in your project:

require_once 'WinSCP.php';

🔧 Usage

Password Encryption

// Encrypt a password
$encrypted = WinSCP::encryptPassword('username', 'hostname.com', 'plaintext_password');
echo $encrypted; // A35C4F5BC9639256174DAC2E3333286D726E726F72682C3D2F...

// Decrypt a password
$decrypted = WinSCP::decryptPassword('username', 'hostname.com', $encrypted);
echo $decrypted; // plaintext_password

JSON to INI Conversion

// Convert JSON configuration to WinSCP INI format
$iniContent = WinSCP::convertJsonToIni('sessions.json');
file_put_contents('sessions.ini', $iniContent);

// Or save directly to file
WinSCP::convertJsonToIni('sessions.json', 'output.ini');

INI to JSON Conversion

// Convert WinSCP INI to JSON format
$jsonData = WinSCP::convertIniToJson('sessions.ini');
file_put_contents('sessions.json', json_encode($jsonData, JSON_PRETTY_PRINT));

// Or save directly to file
WinSCP::convertIniToJson('sessions.ini', 'output.json');

📋 JSON Format

The library expects JSON files with the following structure:

{
  "sessions": [
    {
      "name": "production-server",
      "hostname": "prod.example.com",
      "port": 22,
      "username": "root",
      "password": "secure_password"
    },
    {
      "category": "Development",
      "hosts": [
        {
          "name": "dev-server",
          "hostname": "dev.example.com",
          "port": 2222,
          "username": "developer",
          "password": "dev_password"
        }
      ]
    }
  ]
}

🔐 Security Features

  • WinSCP Compatible: Passwords encrypted with this library work directly in WinSCP
  • Secure Algorithm: Uses WinSCP's proprietary encryption algorithm
  • Random Padding: Includes random padding for additional security
  • Bidirectional: Can encrypt new passwords and decrypt existing WinSCP passwords

🧪 Testing

Run the included test file to verify functionality:

php temp/test.php

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📞 Support

If you encounter any issues or have questions, please open an issue on GitHub.


Made with ❤️ by AriaData

About

PHP library for encrypt and decrypt winscp passwords

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages