| @@ -3,17 +3,17 @@ | ||
| 3 | 3 | |
| 4 | 4 | interface Suitin | 
| 5 | 5 |  {
 | 
| 6 | - public function cost($cost); | |
| 6 | + public function cost($cost); | |
| 7 | 7 | |
| 8 | - public function memory($memory); | |
| 8 | + public function memory($memory); | |
| 9 | 9 | |
| 10 | - public function time($time); | |
| 10 | + public function time($time); | |
| 11 | 11 | |
| 12 | - public function thread($thread); | |
| 12 | + public function thread($thread); | |
| 13 | 13 | |
| 14 | - public function pwHash($mode, $password); | |
| 14 | + public function pwHash($mode, $password); | |
| 15 | 15 | |
| 16 | - public function pwRehash($mode, $password, $hash); | |
| 16 | + public function pwRehash($mode, $password, $hash); | |
| 17 | 17 | |
| 18 | - public function pwInfo($hash); | |
| 18 | + public function pwInfo($hash); | |
| 19 | 19 | } | 
| @@ -19,35 +19,35 @@ discard block | ||
| 19 | 19 | class Pwsuit | 
| 20 | 20 |  {
 | 
| 21 | 21 | /** | 
| 22 | - * @param int $cost | |
| 23 | - */ | |
| 22 | + * @param int $cost | |
| 23 | + */ | |
| 24 | 24 | protected static $cost; | 
| 25 | 25 | |
| 26 | 26 | /** | 
| 27 | - * @param int $memory | |
| 28 | - */ | |
| 27 | + * @param int $memory | |
| 28 | + */ | |
| 29 | 29 | protected static $memory; | 
| 30 | 30 | |
| 31 | 31 | /** | 
| 32 | - * @param int $time | |
| 33 | - */ | |
| 32 | + * @param int $time | |
| 33 | + */ | |
| 34 | 34 | protected static $time; | 
| 35 | 35 | |
| 36 | 36 | /** | 
| 37 | - * @param int $thread | |
| 38 | - */ | |
| 37 | + * @param int $thread | |
| 38 | + */ | |
| 39 | 39 | protected static $thread; | 
| 40 | 40 | |
| 41 | 41 | /** | 
| 42 | - * Set default | |
| 43 | - */ | |
| 42 | + * Set default | |
| 43 | + */ | |
| 44 | 44 | const DEFAULT = 'Default'; | 
| 45 | 45 | |
| 46 | 46 | /** | 
| 47 | - * Require minimum PHP 5.6+ | |
| 48 | - * | |
| 49 | - * @throws RuntimeException | |
| 50 | - */ | |
| 47 | + * Require minimum PHP 5.6+ | |
| 48 | + * | |
| 49 | + * @throws RuntimeException | |
| 50 | + */ | |
| 51 | 51 | public function __construct() | 
| 52 | 52 |      {
 | 
| 53 | 53 |          if (version_compare(PHP_VERSION, '5.6.0', '<')) {
 | 
| @@ -56,16 +56,16 @@ discard block | ||
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | /** | 
| 59 | - * Create cost length | |
| 60 | - * | |
| 61 | - * if it doesn't set by default a cost will set to 14 | |
| 62 | - * do not set under native default by php | |
| 63 | - * native default by php set to 10 | |
| 64 | - * | |
| 65 | - * @param int $length | |
| 66 | - * @return array | |
| 67 | - * | |
| 68 | - */ | |
| 59 | + * Create cost length | |
| 60 | + * | |
| 61 | + * if it doesn't set by default a cost will set to 14 | |
| 62 | + * do not set under native default by php | |
| 63 | + * native default by php set to 10 | |
| 64 | + * | |
| 65 | + * @param int $length | |
| 66 | + * @return array | |
| 67 | + * | |
| 68 | + */ | |
| 69 | 69 | public static function cost(int $length) | 
| 70 | 70 |      {
 | 
| 71 | 71 | static::$cost[Verbal::DEFAULT_COST] = $length; | 
| @@ -74,16 +74,16 @@ discard block | ||
| 74 | 74 | } | 
| 75 | 75 | |
| 76 | 76 | /** | 
| 77 | - * Create memory_cost length | |
| 78 | - * | |
| 79 | - * This is optional by default memory_cost will set to 1666 | |
| 80 | - * do not set under native default by php | |
| 81 | - * native default by php set to 1024 | |
| 82 | - * | |
| 83 | - * @param int $length | |
| 84 | - * @return array | |
| 85 | - * | |
| 86 | - */ | |
| 77 | + * Create memory_cost length | |
| 78 | + * | |
| 79 | + * This is optional by default memory_cost will set to 1666 | |
| 80 | + * do not set under native default by php | |
| 81 | + * native default by php set to 1024 | |
| 82 | + * | |
| 83 | + * @param int $length | |
| 84 | + * @return array | |
| 85 | + * | |
| 86 | + */ | |
| 87 | 87 | public static function memory(int $length) | 
| 88 | 88 |      {
 | 
| 89 | 89 | static::$memory[Verbal::MEMORY_KEY] = $length; | 
| @@ -92,15 +92,15 @@ discard block | ||
| 92 | 92 | } | 
| 93 | 93 | |
| 94 | 94 | /** | 
| 95 | - * Create time_cost length | |
| 96 | - * | |
| 97 | - * This is optional by default time_cost will set to 6 | |
| 98 | - * do not set under native default by php | |
| 99 | - * native default by php set to 2 | |
| 100 | - * | |
| 101 | - * @param int $length | |
| 102 | - * @return array | |
| 103 | - */ | |
| 95 | + * Create time_cost length | |
| 96 | + * | |
| 97 | + * This is optional by default time_cost will set to 6 | |
| 98 | + * do not set under native default by php | |
| 99 | + * native default by php set to 2 | |
| 100 | + * | |
| 101 | + * @param int $length | |
| 102 | + * @return array | |
| 103 | + */ | |
| 104 | 104 | public function time(int $length) | 
| 105 | 105 |      {
 | 
| 106 | 106 | static::$time[Verbal::TIME_KEY] = $length; | 
| @@ -109,15 +109,15 @@ discard block | ||
| 109 | 109 | } | 
| 110 | 110 | |
| 111 | 111 | /** | 
| 112 | - * Create threads length | |
| 113 | - * | |
| 114 | - * This is optional by default threads will set to 6 | |
| 115 | - * do not set under native default by php | |
| 116 | - * native default by php set to 2 | |
| 117 | - * | |
| 118 | - * @param int $length | |
| 119 | - * @return array | |
| 120 | - */ | |
| 112 | + * Create threads length | |
| 113 | + * | |
| 114 | + * This is optional by default threads will set to 6 | |
| 115 | + * do not set under native default by php | |
| 116 | + * native default by php set to 2 | |
| 117 | + * | |
| 118 | + * @param int $length | |
| 119 | + * @return array | |
| 120 | + */ | |
| 121 | 121 | public function thread(int $length) | 
| 122 | 122 |      {
 | 
| 123 | 123 | static::$thread[Verbal::THREAD_KEY] = $length; | 
| @@ -126,45 +126,45 @@ discard block | ||
| 126 | 126 | } | 
| 127 | 127 | |
| 128 | 128 | /** | 
| 129 | - * Check attributes operation | |
| 130 | - * | |
| 131 | - * @return array | |
| 132 | - */ | |
| 129 | + * Check attributes operation | |
| 130 | + * | |
| 131 | + * @return array | |
| 132 | + */ | |
| 133 | 133 | protected static function getLength() | 
| 134 | 134 |      {
 | 
| 135 | 135 | return isset(static::$cost) ? static::$cost : static::costLength(); | 
| 136 | 136 | } | 
| 137 | 137 | |
| 138 | 138 | /** | 
| 139 | - * Check attributes for eg. password Argon | |
| 140 | - * | |
| 141 | - * @return array | |
| 142 | - */ | |
| 139 | + * Check attributes for eg. password Argon | |
| 140 | + * | |
| 141 | + * @return array | |
| 142 | + */ | |
| 143 | 143 | protected static function getOptions() | 
| 144 | 144 |      {
 | 
| 145 | 145 | return isset(static::$memory) ? static::hashel() : static::options(); | 
| 146 | 146 | } | 
| 147 | 147 | |
| 148 | 148 | /** | 
| 149 | - * Generate default values if attributes exist | |
| 150 | - * eg. Password Argon | |
| 151 | - * | |
| 152 | - * @return array | |
| 153 | - * | |
| 154 | - */ | |
| 149 | + * Generate default values if attributes exist | |
| 150 | + * eg. Password Argon | |
| 151 | + * | |
| 152 | + * @return array | |
| 153 | + * | |
| 154 | + */ | |
| 155 | 155 | protected static function hashel() | 
| 156 | 156 |      {
 | 
| 157 | 157 | return array_merge(static::$memory, static::$time, static::$thread); | 
| 158 | 158 | } | 
| 159 | 159 | |
| 160 | 160 | /** | 
| 161 | - * Check the current attributes that use for compatible version | |
| 162 | - * if doesn't set will return to default config | |
| 163 | - * | |
| 164 | - * @param string $hashmode | |
| 165 | - * @param string $key | |
| 166 | - * @return string | |
| 167 | - */ | |
| 161 | + * Check the current attributes that use for compatible version | |
| 162 | + * if doesn't set will return to default config | |
| 163 | + * | |
| 164 | + * @param string $hashmode | |
| 165 | + * @param string $key | |
| 166 | + * @return string | |
| 167 | + */ | |
| 168 | 168 | public static function pwHash($hashmode, $key) | 
| 169 | 169 |      {		
 | 
| 170 | 170 | $options = ($hashmode !== self::DEFAULT && version_compare(PHP_VERSION, '7.2.0', '>=')) ? static::getOptions() : static::getLength(); | 
| @@ -173,15 +173,15 @@ discard block | ||
| 173 | 173 | } | 
| 174 | 174 | |
| 175 | 175 | /** | 
| 176 | - * Create new hashed with the old hashed password | |
| 177 | - * and check for compatible php version | |
| 178 | - * if match will produce new hashed | |
| 179 | - * | |
| 180 | - * @param string $hashmode | |
| 181 | - * @param string $password | |
| 182 | - * @param string $datahash | |
| 183 | - * @return Moviet\Heavy\Exceptions\EqualsException | |
| 184 | - */ | |
| 176 | + * Create new hashed with the old hashed password | |
| 177 | + * and check for compatible php version | |
| 178 | + * if match will produce new hashed | |
| 179 | + * | |
| 180 | + * @param string $hashmode | |
| 181 | + * @param string $password | |
| 182 | + * @param string $datahash | |
| 183 | + * @return Moviet\Heavy\Exceptions\EqualsException | |
| 184 | + */ | |
| 185 | 185 | public static function pwRehash($hashmode, $password, $datahash) | 
| 186 | 186 |      {
 | 
| 187 | 187 | $options = ($hashmode !== self::DEFAULT && version_compare(PHP_VERSION, '7.2.0', '>=')) ? static::getOptions() : static::getLength(); | 
| @@ -197,20 +197,20 @@ discard block | ||
| 197 | 197 | } | 
| 198 | 198 | |
| 199 | 199 | /** | 
| 200 | - * Generate default cost length | |
| 201 | - * | |
| 202 | - * @return array | |
| 203 | - */ | |
| 200 | + * Generate default cost length | |
| 201 | + * | |
| 202 | + * @return array | |
| 203 | + */ | |
| 204 | 204 | protected static function costLength() | 
| 205 | 205 |      {
 | 
| 206 | 206 | return [Verbal::DEFAULT_COST => Verbal::DEFAULT_COST_LENGTH]; | 
| 207 | 207 | } | 
| 208 | 208 | |
| 209 | 209 | /** | 
| 210 | - * Generate default memory, time, threads for password Argon | |
| 211 | - * | |
| 212 | - * @return array | |
| 213 | - */ | |
| 210 | + * Generate default memory, time, threads for password Argon | |
| 211 | + * | |
| 212 | + * @return array | |
| 213 | + */ | |
| 214 | 214 | protected static function options() | 
| 215 | 215 |      {
 | 
| 216 | 216 | return [Verbal::MEMORY_KEY => Verbal::DEFAULT_MEMORY_COST, Verbal::TIME_KEY => Verbal::DEFAULT_TIME_COST, | 
| @@ -218,23 +218,23 @@ discard block | ||
| 218 | 218 | } | 
| 219 | 219 | |
| 220 | 220 | /** | 
| 221 | - * Generate password verification | |
| 222 | - * | |
| 223 | - * @param string $password | |
| 224 | - * @param string $hash | |
| 225 | - * @return bool | |
| 226 | - */ | |
| 221 | + * Generate password verification | |
| 222 | + * | |
| 223 | + * @param string $password | |
| 224 | + * @param string $hash | |
| 225 | + * @return bool | |
| 226 | + */ | |
| 227 | 227 | public static function pwTrust($password, $hash) | 
| 228 | 228 |      {
 | 
| 229 | 229 | return password_verify($password, $hash); | 
| 230 | 230 | } | 
| 231 | 231 | |
| 232 | 232 | /** | 
| 233 | - * Generate password information | |
| 234 | - * | |
| 235 | - * @param string $hash | |
| 236 | - * @return array | |
| 237 | - */ | |
| 233 | + * Generate password information | |
| 234 | + * | |
| 235 | + * @param string $hash | |
| 236 | + * @return array | |
| 237 | + */ | |
| 238 | 238 | public static function pwInfo($hash) | 
| 239 | 239 |      {
 | 
| 240 | 240 | return password_get_info($hash); | 
| @@ -73,11 +73,11 @@ | ||
| 73 | 73 | const DEFAULT_THREAD_LENGTH = 6; | 
| 74 | 74 | |
| 75 | 75 | /** | 
| 76 | - * Generate password compatible suits | |
| 77 | - * | |
| 78 | - * @param string $algorithm | |
| 79 | - * @return string | |
| 80 | - */ | |
| 76 | + * Generate password compatible suits | |
| 77 | + * | |
| 78 | + * @param string $algorithm | |
| 79 | + * @return string | |
| 80 | + */ | |
| 81 | 81 | public static function hashAlgo($algorithm) | 
| 82 | 82 |      {
 | 
| 83 | 83 |          switch ($algorithm) {
 | 
| @@ -24,35 +24,35 @@ discard block | ||
| 24 | 24 | class Crypsic | 
| 25 | 25 |  {
 | 
| 26 | 26 | /** | 
| 27 | - * @param string key | |
| 28 | - */ | |
| 27 | + * @param string key | |
| 28 | + */ | |
| 29 | 29 | protected static $key; | 
| 30 | 30 | |
| 31 | 31 | /** | 
| 32 | - * @param string key | |
| 33 | - */ | |
| 32 | + * @param string key | |
| 33 | + */ | |
| 34 | 34 | protected static $has; | 
| 35 | 35 | |
| 36 | 36 | /** | 
| 37 | - * @param string password | |
| 38 | - */ | |
| 37 | + * @param string password | |
| 38 | + */ | |
| 39 | 39 | protected static $auth; | 
| 40 | 40 | |
| 41 | 41 | /** | 
| 42 | - * @param string hash | |
| 43 | - */ | |
| 42 | + * @param string hash | |
| 43 | + */ | |
| 44 | 44 | protected static $hash; | 
| 45 | 45 | |
| 46 | 46 | /** | 
| 47 | - * @param string cipher | |
| 48 | - */ | |
| 47 | + * @param string cipher | |
| 48 | + */ | |
| 49 | 49 | protected static $mode; | 
| 50 | 50 | |
| 51 | 51 | /** | 
| 52 | - * Check requirements | |
| 53 | - * | |
| 54 | - * @throws RunTimeException; | |
| 55 | - */ | |
| 52 | + * Check requirements | |
| 53 | + * | |
| 54 | + * @throws RunTimeException; | |
| 55 | + */ | |
| 56 | 56 | public function __construct() | 
| 57 | 57 |      {
 | 
| 58 | 58 |          if (!extension_loaded('openssl')) {
 | 
| @@ -69,22 +69,22 @@ discard block | ||
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 | /** | 
| 72 | - * Generate key from any storage | |
| 73 | - * and use a key to validate | |
| 74 | - * | |
| 75 | - * @param string $key | |
| 76 | - */ | |
| 72 | + * Generate key from any storage | |
| 73 | + * and use a key to validate | |
| 74 | + * | |
| 75 | + * @param string $key | |
| 76 | + */ | |
| 77 | 77 | public static function key($key) | 
| 78 | 78 |      {
 | 
| 79 | 79 | self::$has = self::h2bin($key); | 
| 80 | 80 | } | 
| 81 | 81 | |
| 82 | 82 | /** | 
| 83 | - * Generate mac and build a nice salt | |
| 84 | - * this is use to authenticated crypto | |
| 85 | - * | |
| 86 | - * @return string | |
| 87 | - */ | |
| 83 | + * Generate mac and build a nice salt | |
| 84 | + * this is use to authenticated crypto | |
| 85 | + * | |
| 86 | + * @return string | |
| 87 | + */ | |
| 88 | 88 | protected static function suitSalt() | 
| 89 | 89 |      {
 | 
| 90 | 90 | return hash_hmac( | 
| @@ -93,10 +93,10 @@ discard block | ||
| 93 | 93 | } | 
| 94 | 94 | |
| 95 | 95 | /** | 
| 96 | - * Load password from any request | |
| 97 | - * | |
| 98 | - * @param string $password | |
| 99 | - */ | |
| 96 | + * Load password from any request | |
| 97 | + * | |
| 98 | + * @param string $password | |
| 99 | + */ | |
| 100 | 100 | public static function authKey($password) | 
| 101 | 101 |      {
 | 
| 102 | 102 | self::$auth = (string) $password; | 
| @@ -105,10 +105,10 @@ discard block | ||
| 105 | 105 | } | 
| 106 | 106 | |
| 107 | 107 | /** | 
| 108 | - * Load data password from any storage | |
| 109 | - * | |
| 110 | - * @param string $datahash | |
| 111 | - */ | |
| 108 | + * Load data password from any storage | |
| 109 | + * | |
| 110 | + * @param string $datahash | |
| 111 | + */ | |
| 112 | 112 | public function hash($datahash) | 
| 113 | 113 |      {
 | 
| 114 | 114 | self::$hash = (string) $datahash; | 
| @@ -117,45 +117,45 @@ discard block | ||
| 117 | 117 | } | 
| 118 | 118 | |
| 119 | 119 | /** | 
| 120 | - * You encoded, you responsible to decoded | |
| 121 | - * just make it readable yayy | |
| 122 | - * | |
| 123 | - * @param string $string | |
| 124 | - */ | |
| 120 | + * You encoded, you responsible to decoded | |
| 121 | + * just make it readable yayy | |
| 122 | + * | |
| 123 | + * @param string $string | |
| 124 | + */ | |
| 125 | 125 | public static function listen($string) | 
| 126 | 126 |      {
 | 
| 127 | 127 | return base64_encode(self::cipherBlock($string)); | 
| 128 | 128 | } | 
| 129 | 129 | |
| 130 | 130 | /** | 
| 131 | - * Just simply decoded the ciphertext | |
| 132 | - * | |
| 133 | - * @param string $string | |
| 134 | - */ | |
| 131 | + * Just simply decoded the ciphertext | |
| 132 | + * | |
| 133 | + * @param string $string | |
| 134 | + */ | |
| 135 | 135 | public static function look($string) | 
| 136 | 136 |      {
 | 
| 137 | 137 | return self::record(base64_decode($string)); | 
| 138 | 138 | } | 
| 139 | 139 | |
| 140 | 140 | /** | 
| 141 | - * Check what the operation modes | |
| 142 | - * | |
| 143 | - * @return string | |
| 144 | - */ | |
| 141 | + * Check what the operation modes | |
| 142 | + * | |
| 143 | + * @return string | |
| 144 | + */ | |
| 145 | 145 | protected static function combatKey() | 
| 146 | 146 |      {
 | 
| 147 | 147 | return self::suitSalt(); | 
| 148 | 148 | } | 
| 149 | 149 | |
| 150 | 150 | /** | 
| 151 | - * Check parameter key if they use password | |
| 152 | - * then verify the absolete if not then | |
| 153 | - * we can authentify next | |
| 154 | - * | |
| 155 | - * @throws Moviet\Heavy\Exceptions\EqualsException | |
| 156 | - * @throws Moviet\Heavy\Exceptions\EqualsException | |
| 157 | - * @return bool | |
| 158 | - */ | |
| 151 | + * Check parameter key if they use password | |
| 152 | + * then verify the absolete if not then | |
| 153 | + * we can authentify next | |
| 154 | + * | |
| 155 | + * @throws Moviet\Heavy\Exceptions\EqualsException | |
| 156 | + * @throws Moviet\Heavy\Exceptions\EqualsException | |
| 157 | + * @return bool | |
| 158 | + */ | |
| 159 | 159 | protected static function verify() | 
| 160 | 160 |      {
 | 
| 161 | 161 |          if (!is_null(self::$hash)) {
 | 
| @@ -166,13 +166,13 @@ discard block | ||
| 166 | 166 | } | 
| 167 | 167 | |
| 168 | 168 | /** | 
| 169 | - * Compact the string, cipher modes, a key and ivector | |
| 170 | - * and just make a zig-zag onto natively | |
| 171 | - * | |
| 172 | - * @param string | |
| 173 | - * @param mixed | |
| 174 | - * @return mixed | |
| 175 | - */ | |
| 169 | + * Compact the string, cipher modes, a key and ivector | |
| 170 | + * and just make a zig-zag onto natively | |
| 171 | + * | |
| 172 | + * @param string | |
| 173 | + * @param mixed | |
| 174 | + * @return mixed | |
| 175 | + */ | |
| 176 | 176 | protected static function crypto($string, $nonce) | 
| 177 | 177 |      {
 | 
| 178 | 178 | return openssl_encrypt( | 
| @@ -181,11 +181,11 @@ discard block | ||
| 181 | 181 | } | 
| 182 | 182 | |
| 183 | 183 | /** | 
| 184 | - * Generate and compact all the chunks here | |
| 185 | - * and deliver the raw crypto | |
| 186 | - * | |
| 187 | - * @return mixed | |
| 188 | - */ | |
| 184 | + * Generate and compact all the chunks here | |
| 185 | + * and deliver the raw crypto | |
| 186 | + * | |
| 187 | + * @return mixed | |
| 188 | + */ | |
| 189 | 189 | protected static function cipherBlock($string) | 
| 190 | 190 |      {
 | 
| 191 | 191 | $nonce = self::nonceCash(); | 
| @@ -194,13 +194,13 @@ discard block | ||
| 194 | 194 | } | 
| 195 | 195 | |
| 196 | 196 | /** | 
| 197 | - * Generate mac, salt and bandage the raw crypto | |
| 198 | - * so we can get assosiated data | |
| 199 | - * | |
| 200 | - * @param string | |
| 201 | - * @param mixed | |
| 202 | - * @return string | |
| 203 | - */ | |
| 197 | + * Generate mac, salt and bandage the raw crypto | |
| 198 | + * so we can get assosiated data | |
| 199 | + * | |
| 200 | + * @param string | |
| 201 | + * @param mixed | |
| 202 | + * @return string | |
| 203 | + */ | |
| 204 | 204 | protected static function hmac($string, $nonce) | 
| 205 | 205 |      {
 | 
| 206 | 206 | return hash_hmac( | 
| @@ -209,10 +209,10 @@ discard block | ||
| 209 | 209 | } | 
| 210 | 210 | |
| 211 | 211 | /** | 
| 212 | - * Generate initial vector for spesific cipher | |
| 213 | - * | |
| 214 | - * @return mixed | |
| 215 | - */ | |
| 212 | + * Generate initial vector for spesific cipher | |
| 213 | + * | |
| 214 | + * @return mixed | |
| 215 | + */ | |
| 216 | 216 | protected static function nonceCash() | 
| 217 | 217 |      {
 | 
| 218 | 218 |          if (!function_exists('random_bytes')) {
 | 
| @@ -224,16 +224,16 @@ discard block | ||
| 224 | 224 | } | 
| 225 | 225 | |
| 226 | 226 | /** | 
| 227 | - * Now we check the mac for something called 'noin bullet' | |
| 228 | - * then check what the key that was generated | |
| 229 | - * if they use a password so we must proof it | |
| 230 | - * and compare the spesific length | |
| 231 | - * | |
| 232 | - * @param string $string | |
| 233 | - * @throws Moviet\Heavy\Exceptions\EqualsException | |
| 234 | - * @throws Moviet\Heavy\Exceptions\DecryptException | |
| 235 | - * @return mixed | |
| 236 | - */ | |
| 227 | + * Now we check the mac for something called 'noin bullet' | |
| 228 | + * then check what the key that was generated | |
| 229 | + * if they use a password so we must proof it | |
| 230 | + * and compare the spesific length | |
| 231 | + * | |
| 232 | + * @param string $string | |
| 233 | + * @throws Moviet\Heavy\Exceptions\EqualsException | |
| 234 | + * @throws Moviet\Heavy\Exceptions\DecryptException | |
| 235 | + * @return mixed | |
| 236 | + */ | |
| 237 | 237 | protected static function record($string) | 
| 238 | 238 |      {		
 | 
| 239 | 239 |          if (!hash_equals(self::compare($string), self::screw($string))) {
 | 
| @@ -251,10 +251,10 @@ discard block | ||
| 251 | 251 | } | 
| 252 | 252 | |
| 253 | 253 | /** | 
| 254 | - * Here the bytes crypto must not be invalid | |
| 255 | - * | |
| 256 | - * @return mixed | |
| 257 | - */ | |
| 254 | + * Here the bytes crypto must not be invalid | |
| 255 | + * | |
| 256 | + * @return mixed | |
| 257 | + */ | |
| 258 | 258 | protected static function rotate($string) | 
| 259 | 259 |      {
 | 
| 260 | 260 | return mb_substr( | 
| @@ -263,10 +263,10 @@ discard block | ||
| 263 | 263 | } | 
| 264 | 264 | |
| 265 | 265 | /** | 
| 266 | - * Screw up the bytes size to compare | |
| 267 | - * | |
| 268 | - * @return mixed | |
| 269 | - */ | |
| 266 | + * Screw up the bytes size to compare | |
| 267 | + * | |
| 268 | + * @return mixed | |
| 269 | + */ | |
| 270 | 270 | protected static function screw($string) | 
| 271 | 271 |      {
 | 
| 272 | 272 | return mb_substr( | 
| @@ -275,10 +275,10 @@ discard block | ||
| 275 | 275 | } | 
| 276 | 276 | |
| 277 | 277 | /** | 
| 278 | - * Round up the crypto in spesific length | |
| 279 | - * | |
| 280 | - * @return mixed | |
| 281 | - */ | |
| 278 | + * Round up the crypto in spesific length | |
| 279 | + * | |
| 280 | + * @return mixed | |
| 281 | + */ | |
| 282 | 282 | protected static function round($string) | 
| 283 | 283 |      {
 | 
| 284 | 284 | return mb_substr( | 
| @@ -287,11 +287,11 @@ discard block | ||
| 287 | 287 | } | 
| 288 | 288 | |
| 289 | 289 | /** | 
| 290 | - * Now we host an assosiated salt | |
| 291 | - * to authenticate the data | |
| 292 | - * | |
| 293 | - * @return mixed | |
| 294 | - */ | |
| 290 | + * Now we host an assosiated salt | |
| 291 | + * to authenticate the data | |
| 292 | + * | |
| 293 | + * @return mixed | |
| 294 | + */ | |
| 295 | 295 | protected static function compare($string) | 
| 296 | 296 |      {
 | 
| 297 | 297 | return hash_hmac( | 
| @@ -300,11 +300,11 @@ discard block | ||
| 300 | 300 | } | 
| 301 | 301 | |
| 302 | 302 | /** | 
| 303 | - * Calculate key for acceptable cipher mode | |
| 304 | - * | |
| 305 | - * @param string $key | |
| 306 | - * @return int | |
| 307 | - */ | |
| 303 | + * Calculate key for acceptable cipher mode | |
| 304 | + * | |
| 305 | + * @param string $key | |
| 306 | + * @return int | |
| 307 | + */ | |
| 308 | 308 | protected static function guideKey($key) | 
| 309 | 309 |      {
 | 
| 310 | 310 | $length = mb_strlen($key, Verbal::CHBYTES); | 
| @@ -323,20 +323,20 @@ discard block | ||
| 323 | 323 | } | 
| 324 | 324 | |
| 325 | 325 | /** | 
| 326 | - * Set cooperative cipher mode | |
| 327 | - * | |
| 328 | - * @param string $cipher | |
| 329 | - */ | |
| 326 | + * Set cooperative cipher mode | |
| 327 | + * | |
| 328 | + * @param string $cipher | |
| 329 | + */ | |
| 330 | 330 | public static function mode($cipher) | 
| 331 | 331 |      {
 | 
| 332 | 332 | self::$mode = Verbal::BLOCK_MODE[$cipher]; | 
| 333 | 333 | } | 
| 334 | 334 | |
| 335 | 335 | /** | 
| 336 | - * Get cipher mode, if nothing, set to default mode | |
| 337 | - * | |
| 338 | - * @return string | |
| 339 | - */ | |
| 336 | + * Get cipher mode, if nothing, set to default mode | |
| 337 | + * | |
| 338 | + * @return string | |
| 339 | + */ | |
| 340 | 340 | protected static function getMode() | 
| 341 | 341 |      {
 | 
| 342 | 342 |          if (isset(self::$mode)) {
 | 
| @@ -350,46 +350,46 @@ discard block | ||
| 350 | 350 | } | 
| 351 | 351 | |
| 352 | 352 | /** | 
| 353 | - * Checking cipher operation mode | |
| 354 | - * | |
| 355 | - * @return int | |
| 356 | - */ | |
| 353 | + * Checking cipher operation mode | |
| 354 | + * | |
| 355 | + * @return int | |
| 356 | + */ | |
| 357 | 357 | protected static function calcKey() | 
| 358 | 358 |      {
 | 
| 359 | 359 |          return preg_replace('/[^0-9]/','', self::getMode());
 | 
| 360 | 360 | } | 
| 361 | 361 | |
| 362 | 362 | /** | 
| 363 | - * We must generate a readable key | |
| 364 | - * | |
| 365 | - * @param string $length | |
| 366 | - * @return string | |
| 367 | - */ | |
| 363 | + * We must generate a readable key | |
| 364 | + * | |
| 365 | + * @param string $length | |
| 366 | + * @return string | |
| 367 | + */ | |
| 368 | 368 | protected static function b2hex($length) | 
| 369 | 369 |      {
 | 
| 370 | 370 | return bin2hex($length); | 
| 371 | 371 | } | 
| 372 | 372 | |
| 373 | 373 | /** | 
| 374 | - * We must reverse the key to generate cipher | |
| 375 | - * and get the requirement length | |
| 376 | - * | |
| 377 | - * @param string $length | |
| 378 | - * @return string | |
| 379 | - */ | |
| 374 | + * We must reverse the key to generate cipher | |
| 375 | + * and get the requirement length | |
| 376 | + * | |
| 377 | + * @param string $length | |
| 378 | + * @return string | |
| 379 | + */ | |
| 380 | 380 | protected static function h2bin($length) | 
| 381 | 381 |      {
 | 
| 382 | 382 | return hex2bin($length); | 
| 383 | 383 | } | 
| 384 | 384 | |
| 385 | 385 | /** | 
| 386 | - * Generate random key with minimum requirement | |
| 387 | - * if a length does look badass, says 4 bytes | |
| 388 | - * we prevent with calculation and make it readable | |
| 389 | - * | |
| 390 | - * @param string $key | |
| 391 | - * @return string | |
| 392 | - */ | |
| 386 | + * Generate random key with minimum requirement | |
| 387 | + * if a length does look badass, says 4 bytes | |
| 388 | + * we prevent with calculation and make it readable | |
| 389 | + * | |
| 390 | + * @param string $key | |
| 391 | + * @return string | |
| 392 | + */ | |
| 393 | 393 | public static function saveKey($key) | 
| 394 | 394 |      {
 | 
| 395 | 395 |          if (!function_exists('random_bytes')) {
 | 
| @@ -403,10 +403,10 @@ discard block | ||
| 403 | 403 | } | 
| 404 | 404 | |
| 405 | 405 | /** | 
| 406 | - * Get key to generate crypto | |
| 407 | - * | |
| 408 | - * @return mixed | |
| 409 | - */ | |
| 406 | + * Get key to generate crypto | |
| 407 | + * | |
| 408 | + * @return mixed | |
| 409 | + */ | |
| 410 | 410 | protected static function getKey() | 
| 411 | 411 |      {
 | 
| 412 | 412 | return self::h2bin(self::$key); | 
| @@ -356,7 +356,7 @@ | ||
| 356 | 356 | */ | 
| 357 | 357 | protected static function calcKey() | 
| 358 | 358 |      {
 | 
| 359 | -        return preg_replace('/[^0-9]/','', self::getMode());
 | |
| 359 | +        return preg_replace('/[^0-9]/', '', self::getMode());
 | |
| 360 | 360 | } | 
| 361 | 361 | |
| 362 | 362 | /** |