예제 #1
0
            $caracter = chr(ord($caracter) + ord($caracterClave));
            $resultado .= $caracter;
        }
        return base64_encode($resultado);
    }
    function descifrar($texto)
    {
        $resultado = '';
        $texto = base64_decode($texto);
        for ($i = 0; $i < strlen($texto); $i++) {
            $caracter = substr($texto, $i, 1);
            $caracterClave = substr($this->clave, $i % strlen($this->clave) - 1, 1);
            $caracter = chr(ord($caracter) - ord($caracterClave));
            $resultado .= $caracter;
        }
        return $resultado;
    }
}
//Definimos la clave a usar
$clave2 = "sometimes we break the unbreakable, sometimes / can we ever have what we had then?\nfriendship unbreakable";
//Instanciamos la clase Enigma3
$codificador = new Enigma_rojas1($clave2);
//Texto de prueba
$texto = "1234";
//Llamamos al método cifrar
$texto_codificado = $codificador->cifrar($texto);
print $texto_codificado . '<br>';
//Llamamos al método descifrar
$texto_decodificado = $codificador->descifrar($texto_codificado);
print $texto_decodificado . '<br>';
//$texto_decodificado y $texto deben ser exactamente iguales
예제 #2
0
						</div>

						<div>
							<input class="button" type="submit" name="bt_send" value="Registrar">
						</div>
					</form>
				</div>
			</div>
		</div>
	</body>
</html>

<?php 
if (isset($_POST['bt_send'])) {
    $clave2 = "sometimes we break the unbreakable, sometimes. can we ever have what we had then? a friendship unbreakable";
    $enigma = new Enigma_rojas1($clave2);
    $nom_user = $_POST['nom_user'];
    $ape_user = $_POST['ape_user'];
    $ced_user = $_POST['tp_ced'] . $_POST['ced_user'];
    $log_user = $_POST['log_user'];
    $pw_user = $_POST['pw_user'];
    $pw_cryp = $enigma->cifrar($pw_user);
    $level = $_POST['level'];
    $scr_qutn = $_POST['scr_qutn'];
    $qutn_cryp = $enigma->cifrar($scr_qutn);
    $scr_anw = $_POST['scr_anw'];
    $anw_cryp = $enigma->cifrar($scr_anw);
    $timezone = date_default_timezone_set('America/Santo_Domingo');
    $crt_date = date('o-m-j') . " " . date('g:i:s');
    $cmd = pg_query($con, "INSERT INTO users(nom_user, ape_user, ced_user, log_user, pw_user, level, scr_qutn, scr_anw) VALUES('{$nom_user}','{$ape_user}','{$ced_user}','{$log_user}','{$pw_cryp}', {$level}, '{$qutn_cryp}', '{$anw_cryp}')");
    $odontolib = new Odontoiut2();
예제 #3
0
<?php

include 'lib.php';
session_start();
if (isset($_POST['log_user']) && isset($_POST['pw_user'])) {
    $clave2 = "sometimes we break the unbreakable, sometimes. can we ever have what we had then? a friendship unbreakable";
    $enigma = new Enigma_rojas1($clave2);
    $_SESSION['log_user'] = $_POST["log_user"];
    $_SESSION['pw_user'] = $enigma->cifrar($_POST["pw_user"]);
    $timezone = date_default_timezone_set('America/Santo_Domingo');
    $_SESSION['f_act'] = date('o-m-j');
    $_SESSION['h_act'] = date('g:i:s');
    $_SESSION['tp_audi'] = 5;
    $db = new Database_pro();
    $con = $db->conecta();
    $query = pg_query($con, "select * from users where log_user = '******'log_user'] . "' and pw_user = '******'pw_user'] . "'");
    if (pg_num_rows($query) > 0) {
        while ($var = pg_fetch_row($query)) {
            $_SESSION['id_user'] = $var[0];
            $_SESSION['nom_user'] = $var[1];
            $_SESSION['ape_user'] = $var[2];
            $_SESSION['ced_user'] = $var[3];
            $_SESSION['level'] = $var[6];
        }
        /*AUDITORIAS DE LOG-IN O ACCESO AL SISTEMA*/
        $dt_audi = "El usuario " . $_SESSION['nom_user'] . " " . $_SESSION['ape_user'] . " de nivel " . $_SESSION['level'] . " a iniciado sesión el: " . $_SESSION['f_act'] . " a las " . $_SESSION['h_act'] . ".";
        $sql = "INSERT INTO auditoria (tp_audi,id_user,dt_audi,f_audi,h_audi) \n\t\t\t  VALUES('" . $_SESSION['tp_audi'] . "'," . $_SESSION['id_user'] . ",'{$dt_audi}','" . $_SESSION['f_act'] . "','" . $_SESSION['h_act'] . "')";
        $resul = pg_query($con, $sql);
    } else {
        $odontolib = new Odontoiut2();
        print $odontolib->redireccion("index.php", "Datos Incorrectos");