<?php
/**
 * simple method to encrypt or decrypt a plain text string
 * initialization vector(IV) has to be the same when encrypting and decrypting
 *
 * @param string $action: can be 'encrypt' or 'decrypt'
 * @param string $string: string to encrypt or decrypt
 *
 * @return string
 */
function encrypt_decrypt($action, $string,$secret_key = "supersecret_key") {
    $output = false;
    $encrypt_method = "AES-256-CBC";
    $secret_iv = 'randomString#12231'; // change this to one more secure
    $key = hash('sha256', $secret_key);

    // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
    $iv = substr(hash('sha256', $secret_iv), 0, 16);
    if ( $action == 'encrypt' ) {
        $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
        $output = base64_encode($output);
    } else if( $action == 'decrypt' ) {
        $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
    }
    return $output;
}

ob_start();  
system('ipconfig /all');  
$mycomsys  = ob_get_contents();  
ob_clean();  
$find_mac  = "Physical";  
$pmac      = strpos($mycomsys, $find_mac);  
$macaddress=substr($mycomsys,($pmac+36),17); 

$dynamic_string = $macaddress;
$secret_key = "847EJDALQIS2PE3UDKA7128409EJA"; // same in the connected applications
$encrypted_string = encrypt_decrypt('encrypt',$dynamic_string,$secret_key);
$decrypted_string = encrypt_decrypt('decrypt',$encrypted_string,$secret_key);
?>