This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Check key size. */ | |
$keySize = strlen($key); | |
$keySizes = mcrypt_enc_get_supported_key_sizes($td); | |
if(count($keySizes) > 0) { | |
/* Encryption method requires a specific key size. */ | |
if(!in_array($keySize, $keySizes)) { | |
phpsec::error('Key is out of range. Should be one of: '. var_export($keySizes ,1)); | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Inject a salt into a password to create the string to be hashed. | |
* @author Audun Larsen <[email protected]> | |
* | |
* @param string $password | |
* Plain-text password. | |
* | |
* @param string $salt | |
* Well, the salt to inject into the password. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get a key from a secret. | |
* What we do is create two different hashes from the secret, combine them | |
* and pick out the number of characters we need. | |
* We used the raw binary output of the hash function for maximum | |
* bit strength (we have 255 chars to choose from, instead of 16). | |
* | |
* @param string $secret | |
* The secret to generate a key from. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo hash('sha256', 'my password'); | |
/* Produserer: bb14292d91c6d0920a5536bb41f3a50f66351b7b9d94c804dfce8a96ca1051f2 */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Set up array with options for the context used by file_get_contents(). */ | |
$opts = array( | |
'http'=>array( | |
'method'=>"GET", | |
'header'=>"Accept-language: en\r\n" . | |
"User-Agent: phpSec (http://phpsec.xqus.com)\r\n" | |
) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Copyright 2011 Audun Larsen. All rights reserved. | |
[email protected] | |
Redistribution and use, with or without modification, | |
are permitted provided that the following condition is met: | |
* Redistribution and use of source code must retain the above copyright notice, | |
this list of conditions and the following disclaimer. |
NewerOlder