Automator_Helpers_Recipe::automator_api_decode_message( string $message, string $secret )

Decode data coming from Automator API.


Parameters Parameters

$message

(string) (Required) Original message string to decode.

$secret

(string) (Required) Secret Key used for encryption


Top ↑

Return Return

(string|array)


Source Source

File: src/core/lib/helpers/class-automator-recipe-helpers.php

	public static function automator_api_decode_message( $message, $secret ) {
		$tokens = false;
		if ( ! empty( $message ) && ! empty( $secret ) ) {
			$message           = base64_decode( $message ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode
			$method            = 'AES128';
			$iv                = substr( $message, 0, 16 );
			$encrypted_message = substr( $message, 16 );
			$tokens            = openssl_decrypt( $encrypted_message, $method, $secret, 0, $iv );
			$tokens            = maybe_unserialize( $tokens );
		}

		return $tokens;
	}