Permalink
Browse files

Converting tabs to spaces

*sigh* Editor defaults… -_-;;
  • Loading branch information...
1 parent b0cb53f commit 1366257ba21298042c410d4504e405967c08c106 @deceze committed Nov 10, 2012
Showing with 34 additions and 34 deletions.
  1. +32 −32 CryptoProvider.php
  2. +2 −2 ICryptoProvider.php
View
@@ -7,37 +7,37 @@
class CryptoProvider implements ICryptoProvider {
- public function getRandomHexString($length) {
- try {
- return $this->getRandomHexStringFromDevRandom($length);
- } catch (\RuntimeException $e) {
- trigger_error($e->getMessage() . ' Falling back to internal generator.', E_USER_NOTICE);
- return $this->getRandomHexStringFromMtRand($length);
- }
- }
-
- protected function getRandomHexStringFromDevRandom($length) {
- static $sources = array('/dev/urandom', '/dev/random');
-
- foreach ($sources as $source) {
- if (is_readable($source)) {
- return bin2hex(file_get_contents($source, false, null, -1, $length / 2));
- }
- }
-
- throw new \RuntimeException('No system source for randomness available.');
- }
-
- protected function getRandomHexStringFromMtRand($length) {
- $hex = null;
- for ($i = 0; $i < $length; $i++) {
- $hex .= base_convert(mt_rand(0, 15), 10, 16);
- }
- return $hex;
- }
-
- public function hash($data, $secret) {
- return hash_hmac('sha512', $data, $secret);
- }
+ public function getRandomHexString($length) {
+ try {
+ return $this->getRandomHexStringFromDevRandom($length);
+ } catch (\RuntimeException $e) {
+ trigger_error($e->getMessage() . ' Falling back to internal generator.', E_USER_NOTICE);
+ return $this->getRandomHexStringFromMtRand($length);
+ }
+ }
+
+ protected function getRandomHexStringFromDevRandom($length) {
+ static $sources = array('/dev/urandom', '/dev/random');
+
+ foreach ($sources as $source) {
+ if (is_readable($source)) {
+ return bin2hex(file_get_contents($source, false, null, -1, $length / 2));
+ }
+ }
+
+ throw new \RuntimeException('No system source for randomness available.');
+ }
+
+ protected function getRandomHexStringFromMtRand($length) {
+ $hex = null;
+ for ($i = 0; $i < $length; $i++) {
+ $hex .= base_convert(mt_rand(0, 15), 10, 16);
+ }
+ return $hex;
+ }
+
+ public function hash($data, $secret) {
+ return hash_hmac('sha512', $data, $secret);
+ }
}
View
@@ -5,7 +5,7 @@
interface ICryptoProvider {
- public function getRandomHexString($length);
- public function hash($data, $secret);
+ public function getRandomHexString($length);
+ public function hash($data, $secret);
}

0 comments on commit 1366257

Please sign in to comment.