<?php


function encriptar ($valor) {
    $clave= 'SADscsaDsfwefSCfsdgffdgfghytdfgrthjyukuikliopoipngFHbDfgvswdsCasdawdqwazsz';
    $method = 'aes-256-cbc';
    $iv = base64_decode("UtqMlwZ4gIYTaAAtaHaVig==");
    return openssl_encrypt ($valor, $method, $clave, false, $iv);
};

 function desencriptar ($valor) {
    $clave= 'SADscsaDsfwefSCfsdgffdgfghytdfgrthjyukuikliopoipngFHbDfgvswdsCasdawdqwazsz';
$method = 'aes-256-cbc';
    $iv = base64_decode("UtqMlwZ4gIYTaAAtaHaVig==");
    $encrypted_data = base64_decode($valor);
    return openssl_decrypt($valor, $method, $clave, false, $iv);
};

function getIV  () {
    $method = 'aes-256-cbc';
    return base64_encode(openssl_random_pseudo_bytes(openssl_cipher_iv_length($method)));
};

?>