Esempio n. 1
0
<?php

function test_verify($pass, $hash)
{
    echo password_verify($pass, $hash) ? "true\n" : "false\n";
}
test_verify('foo', '$2a$07$usesomesillystringforsalt$');
test_verify('rasmusler', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi');
test_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi');
test_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hj');
Esempio n. 2
0
    $data = read_file($filename);
    $json = json_decode($data, true);
    import_key($json['digital_signature']['key_location'][0]);
    $signature = $json['digital_signature']['signature'];
    $testHash = get_hash_from_signature($signature);
    $signData = format_data_to_sign($json);
    if ($signData == $testHash) {
        $resultList = verify_file($data, $signature);
        $result = $resultList[0];
        if ($result->isValid()) {
            echo "Valid", "\n";
        }
    }
}
function test_signing($filename, $outfile)
{
    $data = read_file($filename);
    $json = json_decode($data, true);
    $signData = format_data_to_sign($json);
    $signature = sign_file($signData);
    $json['digital_signature'] = array('key_location' => array('http://12.109.40.15/resource_data/key/key.asc'), 'signature' => $signature, 'key_owner' => '*****@*****.**', 'signing_method' => 'LR-PGP.1.0');
    $jsonString = json_encode($json);
    write_file($outfile, $jsonString);
}
$testFile = '2011-02-28Metadata10.json';
$signedFile = 'signedOutput.json';
test_signing($testFile, $signedFile);
test_verify($signedFile);
?>