PATH:
home
/
thebhoeo
/
.trash
/
backwpup
/
inc
<?php /** * Encrypt / decrypt data using a trivial character substitution algorithm. * * This should never be used, really. However, if neither Open SSL or mcrypt are available, we don't really * have choice for a better double way encryption. * If should consider to require either Open SSL or mcrypt to avoid the usage of this class. * * Normally we should implement an interface, but at the moment with PHP 5.2 and the "poor" autoloader we have, * an interface would just be another file in "/inc" folder causing confusion. Also, I don't want to create an * interface in a file named `class-...php`. When we get rid of PHP 5.2, we setup a better autoloader and we get rid of * WP coding standard, we finally could consider to introduce an interface. */ class BackWPup_Encryption_Fallback { public const PREFIX = 'ENC1$'; /** * Encryption key. * * @var string */ private $key; /** * Encryption key type. * * @var string */ private $key_type; /** * Initialize the fallback encryptor. * * @param string $enc_key Encryption key. * @param string $key_type Key type identifier. */ public function __construct( $enc_key, $key_type ) { $this->key = md5( (string) $enc_key ); $this->key_type = (string) $key_type; } /** * Check whether fallback encryption is supported. * * @return bool */ public static function supported() { // TODO: Decide whether and how to warn about the security risk. return true; } /** * Encrypt a string (Passwords). * * @param string $value Value to encrypt. * * @return string Encrypted string. */ public function encrypt( $value ) { $result = ''; $value_length = strlen( $value ); $key_length = strlen( $this->key ); for ( $i = 0; $i < $value_length; ++$i ) { $char = substr( $value, $i, 1 ); $key_char = substr( $this->key, ( $i % $key_length ) - 1, 1 ); $char = chr( ord( $char ) + ord( $key_char ) ); $result .= $char; } return BackWPup_Encryption::PREFIX . self::PREFIX . $this->key_type . base64_encode( $result ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- Binary-safe encoding. } /** * Decrypt a string (Passwords). * * @param string $value Value to decrypt. * * @return string Decrypted string. */ public function decrypt( $value ) { if ( ! is_string( $value ) || ! $value || 0 !== strpos( $value, BackWPup_Encryption::PREFIX . self::PREFIX . $this->key_type ) ) { return ''; } $no_prefix = substr( $value, strlen( BackWPup_Encryption::PREFIX . self::PREFIX . $this->key_type ) ); $encrypted = base64_decode( $no_prefix, true ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode -- Binary-safe decoding. if ( false === $encrypted ) { return ''; } $result = ''; $encrypted_length = strlen( $encrypted ); $key_length = strlen( $this->key ); for ( $i = 0; $i < $encrypted_length; ++$i ) { $char = substr( $encrypted, $i, 1 ); $key_char = substr( $this->key, ( $i % $key_length ) - 1, 1 ); $char = chr( ord( $char ) - ord( $key_char ) ); $result .= $char; } return $result; } }
[-] class-system-tests-runner.php
[edit]
[-] class-jobtype-dbdump.php
[edit]
[-] class-destination-rsc.php
[edit]
[-] class-encryption.php
[edit]
[-] class-destination-downloader-factory.php
[edit]
[-] class-destination-downloader-interface.php
[edit]
[-] class-destination-ftp-type-ftp.php
[edit]
[-] class-path-fixer.php
[edit]
[-] class-message-box.php
[edit]
[-] class-destination-dropbox-api.php
[edit]
[-] class-option.php
[edit]
[-] class-destination-dropbox-api-request-exception.php
[edit]
[-] class-page-about.php
[edit]
[-] class-migrate.php
[edit]
[-] class-system-requirements.php
[edit]
[-] class-adminbar.php
[edit]
[-] class-msazure-destination-configuration.php
[edit]
[-] class-job.php
[edit]
[-] class-destination-ftp-type-exception.php
[edit]
[-] class-destination-sugarsync-api.php
[edit]
[-] class-download-file-interface.php
[edit]
[-] class-encryption-fallback.php
[edit]
[-] BackWPup.php
[edit]
[-] class-page-backwpup.php
[edit]
[-] class-destination-downloader-data.php
[edit]
[-] class-mysqldump-exception.php
[edit]
[-] class-s3-destination.php
[edit]
[-] class-destination-ftp.php
[edit]
[-] class-cron.php
[edit]
[+]
Notice
[-] class-destination-downloader.php
[edit]
[-] class-destinations.php
[edit]
[-] class-destination-ftp-downloader.php
[edit]
[-] class-destination-dropbox-downloader.php
[edit]
[-] class-download-handler.php
[edit]
[-] class-destination-dropbox.php
[edit]
[-] class-system-tests.php
[edit]
[-] class-destination-folder-downloader.php
[edit]
[-] class-destination-ftp-type.php
[edit]
[-] class-thirdparties.php
[edit]
[-] class-jobtype-wpplugin.php
[edit]
[-] class-directory.php
[edit]
[-] class-recursive-directory.php
[edit]
[-] class-destination-msazure-downloader.php
[edit]
[-] class-destination-connect-interface.php
[edit]
[-] class-install.php
[edit]
[-] class-admin.php
[edit]
[-] class-jobtype-file.php
[edit]
[-] functions.php
[edit]
[+]
Utils
[+]
ThirdParty
[-] class-destination-s3-downloader.php
[edit]
[-] class-destination-rsc-downloader.php
[edit]
[-] class-destination-sugarsync-downloader.php
[edit]
[-] class-destination-email.php
[edit]
[+]
..
[-] class-mysqldump.php
[edit]
[-] class-page-firstbackup.php
[edit]
[-] class-jobtype-wpexp.php
[edit]
[-] class-jobtype-dbcheck.php
[edit]
[-] class-file.php
[edit]
[-] class-sanitize-path.php
[edit]
[+]
Settings
[-] class-destination-s3.php
[edit]
[-] class-page-logs.php
[edit]
[-] class-factory-exception.php
[edit]
[-] class-page-restore.php
[edit]
[+]
dependencies
[-] class-create-archive-exception.php
[edit]
[-] class-page-editjob.php
[edit]
[-] class-page-backups.php
[edit]
[-] class-destination-dropbox-api-exception.php
[edit]
[-] class-create-archive.php
[edit]
[-] class-encryption-openssl.php
[edit]
[-] class-destination-onedrive-config-trait.php
[edit]
[-] class-destination-download-exception.php
[edit]
[-] class-download-file.php
[edit]
[-] class-page-settings.php
[edit]
[-] class-destination-msazure.php
[edit]
[-] class-page-onboarding.php
[edit]
[-] class-destination-folder.php
[edit]
[-] class-jobtypes.php
[edit]
[-] class-destination-connect-exception.php
[edit]
[-] class-destination-sugarsync.php
[edit]
[-] class-page-jobs.php
[edit]
[-] class-destination-sugarsync-api-exception.php
[edit]
[-] class-encryption-mcrypt.php
[edit]