diff --git a/src/Bitpay/Bitauth.php b/src/Bitpay/Bitauth.php index 531e8233..9bcd58f2 100644 --- a/src/Bitpay/Bitauth.php +++ b/src/Bitpay/Bitauth.php @@ -334,32 +334,32 @@ public function validateSin($sin) } /** - * Returns the inititialization size used for a particular cypher + * Returns the inititialization size used for a particular cipher * type. Returns an integer IV size on success or boolean false - * on failure. If no IV is needed for the cypher type and mode, + * on failure. If no IV is needed for the cipher type and mode, * a zero is returned. * - * @param string $cypher_type + * @param string $cipher_type * @return int|bool */ - public function getIVSize($cypher_type = 'MCRYPT_TRIPLEDES') + public function getIVSize($cipher_type = 'MCRYPT_TRIPLEDES') { $block_mode = 'cbc'; - return mcrypt_get_iv_size($cypher_type, $block_mode); + return mcrypt_get_iv_size($cipher_type, $block_mode); } /** * Returns the maximum key size that can be used with a particular - * cypher type. Any key size equal to or less than the returned + * cipher type. Any key size equal to or less than the returned * value are legal key sizes. Depending on if the local mycrypt * extension is linked against 2.2 or 2.3/2.4 the block mode could * be required, hence the if/else statement. * - * @param string $cypher_type + * @param string $cipher_type * @return int */ - public function getKeySize($cypher_type = 'MCRYPT_TRIPLEDES') + public function getKeySize($cipher_type = 'MCRYPT_TRIPLEDES') { $block_mode = 'cbc'; @@ -388,31 +388,31 @@ public function getAlgos() * returns either boolean true/false depending on if the self-test passed * or failed. * - * @param string $cypher_type + * @param string $cipher_type * @return boolean */ - public function algoSelfTest($cypher_type = 'MCRYPT_TRIPLEDES') + public function algoSelfTest($cipher_type = 'MCRYPT_TRIPLEDES') { - return mcrypt_module_self_test($cypher_type); + return mcrypt_module_self_test($cipher_type); } /** * * Encrypts $text based on your $key and $iv. The returned text is * base-64 encoded to make it easier to work with in various scenarios. - * Default cypher is MCRYPT_TRIPLEDES but you can substitute depending + * Default cipher is MCRYPT_TRIPLEDES but you can substitute depending * on your specific encryption needs. * * @param string $text * @param string $key * @param string $iv * @param int $bit_check - * @param string $cypher_type + * @param string $cipher_type * @return string $text * @throws Exception $e * */ - public function encrypt($text, $key = '', $iv = '', $bit_check = 8, $cypher_type = 'MCRYPT_TRIPLEDES') + public function encrypt($text, $key = '', $iv = '', $bit_check = 8, $cipher_type = 'MCRYPT_TRIPLEDES') { try { /* Ensure the key & IV is the same for both encrypt & decrypt. */ @@ -424,7 +424,7 @@ public function encrypt($text, $key = '', $iv = '', $bit_check = 8, $cypher_type $text = $text.chr($text_num); } - $cipher = mcrypt_module_open($cypher_type, '', 'cbc', ''); + $cipher = mcrypt_module_open($cipher_type, '', 'cbc', ''); mcrypt_generic_init($cipher, $key, $iv); $encrypted = mcrypt_generic($cipher, $text); @@ -436,8 +436,8 @@ public function encrypt($text, $key = '', $iv = '', $bit_check = 8, $cypher_type } else { return $text; } - } catch (Exception $e) { - return 'Error in Bitauth::Encrypt(): '.$e->getMessage(); + } catch (\Exception $e) { + throw $e; } } @@ -445,24 +445,24 @@ public function encrypt($text, $key = '', $iv = '', $bit_check = 8, $cypher_type * * Decrypts $text based on your $key and $iv. Make sure you use the same key * and initialization vector that you used when encrypting the $text. Default - * cypher is MCRYPT_TRIPLEDES but you can substitute depending on the cypher + * cipher is MCRYPT_TRIPLEDES but you can substitute depending on the cipher * used for encrypting the text - very important. * * @param string $encrypted_text * @param string $key * @param string $iv * @param int $bit_check - * @param string $cypher_type + * @param string $cipher_type * @return string $text * @throws Exception $e * */ - public function decrypt($encrypted_text, $key = '', $iv = '', $bit_check = 8, $cypher_type = 'MCRYPT_TRIPLEDES') + public function decrypt($encrypted_text, $key = '', $iv = '', $bit_check = 8, $cipher_type = 'MCRYPT_TRIPLEDES') { try { /* Ensure the key & IV is the same for both encrypt & decrypt. */ if (!empty($encrypted_text)) { - $cipher = mcrypt_module_open($cypher_type, '', 'cbc', ''); + $cipher = mcrypt_module_open($cipher_type, '', 'cbc', ''); mcrypt_generic_init($cipher, $key, $iv); $decrypted = mdecrypt_generic($cipher, base64_decode($encrypted_text)); @@ -483,8 +483,8 @@ public function decrypt($encrypted_text, $key = '', $iv = '', $bit_check = 8, $c } else { return $encrypted_text; } - } catch (Exception $e) { - return 'Error in Bitauth::Dncrypt(): '.$e->getMessage(); + } catch (\Exception $e) { + throw $e; } } }