Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
名前空間およびクラス名を変更 v 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
k-holy committed Apr 25, 2014
1 parent 5977e95 commit 7b1c655
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 101 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "volcanus/security",
"homepage": "https://github.com/k-holy/volcanus-security",
"type": "library",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* @license The MIT License (MIT)
*/

namespace Volcanus\Security;
namespace Volcanus\Security\Crypt;

/**
* 可逆パスワード処理インタフェース
* 暗号化処理インタフェース
*
* @author k.holy74@gmail.com
*/
interface ReversiblePasswordProcessorInterface
interface EncryptorInterface
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* @license The MIT License (MIT)
*/

namespace Volcanus\Security;
namespace Volcanus\Security\Crypt;

/**
* Mcryptパスワード処理クラス
* Mcrypt暗号化処理クラス
*
* @author k.holy74@gmail.com
*/
class McryptPasswordProcessor implements ReversiblePasswordProcessorInterface
class McryptEncryptor implements EncryptorInterface
{

const PADDING_PKCS7 = 'pkcs7';
Expand Down Expand Up @@ -66,8 +66,8 @@ public function initialize($configurations = array())
$this->config['algorithm'] = null;
$this->config['mode'] = null;
$this->config['padding'] = self::PADDING_NULL;
$this->config['cryptKey'] = null;
$this->config['cryptIv'] = null;
$this->config['key'] = null;
$this->config['iv'] = null;
$this->config['saltLength'] = 0;
if (!empty($configurations)) {
foreach ($configurations as $name => $value) {
Expand All @@ -94,8 +94,8 @@ public function config($name)
if (isset($value)) {
switch ($name) {
case 'padding':
case 'cryptKey':
case 'cryptIv':
case 'key':
case 'iv':
if (!is_string($value)) {
throw new \InvalidArgumentException(
sprintf('The config "%s" only accepts string.', $name));
Expand Down Expand Up @@ -156,7 +156,7 @@ public function config($name)
*
* @return int 暗号キーのサイズ
*/
public function getCryptKeySize()
public function getKeySize()
{
return mcrypt_enc_get_key_size($this->getModule());
}
Expand All @@ -166,17 +166,17 @@ public function getCryptKeySize()
*
* @return string 暗号キー
*/
public function createCryptKey()
public function createKey()
{
return $this->createRandomBytes($this->getCryptKeySize());
return $this->createRandomBytes($this->getKeySize());
}

/**
* 設定に合わせた暗号初期化ベクトル(IV)のサイズを返します。
*
* @return int 暗号初期化ベクトル(IV)のサイズ
*/
public function getCryptIvSize()
public function getIvSize()
{
return mcrypt_enc_get_iv_size($this->getModule());
}
Expand All @@ -186,9 +186,9 @@ public function getCryptIvSize()
*
* @return string 暗号初期化ベクトル(IV)
*/
public function createCryptIv()
public function createIv()
{
return $this->createRandomBytes($this->getCryptIvSize());
return $this->createRandomBytes($this->getIvSize());
}

/**
Expand Down Expand Up @@ -299,17 +299,17 @@ private function initModule($key = null, $iv = null)
$module = $this->getModule();

if ($key === null || strlen($key) === 0) {
$key = $this->config('cryptKey');
$key = $this->config('key');
}
if ($key === null || strlen($key) === 0) {
throw new \RuntimeException('Set config "cryptKey" for encrypt.');
throw new \RuntimeException('Set config "key" for encrypt.');
}

if ($iv === null || strlen($iv) === 0) {
$iv = $this->config('cryptIv');
$iv = $this->config('iv');
}
if ($iv === null || strlen($iv) === 0) {
throw new \RuntimeException('Set config "cryptIv" for encrypt.');
throw new \RuntimeException('Set config "iv" for encrypt.');
}

$key_size = mcrypt_enc_get_key_size($module);
Expand Down

0 comments on commit 7b1c655

Please sign in to comment.