# Security 소개

## 📌 Encryptor <a href="#encryptor" id="encryptor"></a>

대칭 키 암호화 알고리즘인 `RIJNDAEL 256`(레인달 256)을 이용하여 정보를 보호할수 있고, \
`BCRYPT HASH`를 이용해 패스워드를 관리할 수 있습니다.

### **Encrypt**

```php
$encrypted = Encryptor::encrypt('value');
```

### **Encrypt with salt string**

```php
$encrypted = Encryptor::encrypt('value', 'some salt string');
```

### **Decrypt**

```php
$decrypted = Encryptor::decrypt('value');
```

### **Decrypt with salt string**

```php
$decrypted = Encryptor::decrypt('value', 'some salt string');
```

### **MySQL AES 호환**

MySQL의 AES 함수이 구현되어 있으므로 암호화를 위해 MySQL에 연결하지 않아도 됩니다.

#### **MySQL AES Encrypt**

```php
$encrypted = Encryptor::mysqlAesEncrypt('value', 'some encryption key');
```

#### **MySQL AES Decrypt**

```php
$decrypted = Encryptor::mysqlAesDecrypt('value', 'some encryption key');
```

## 📌 Password <a href="#password" id="password"></a>

### **Hashing**

```php
$hash = Password::hash('somepassword');
```

### **Verifying**

```php
$result = Password::verify('somepassword', $hash);
```

### **Re-Hashing**

```php
// cost 12
$hash = Password::hash('somepassword', ['cost' => 12]);

// 이후에 cost 가 바뀌거나, hash 알고리즘이 바뀐 경우 (검증은 정상적으로 됨)
if (Password::needsRehash($hash, ['cost' => 20])) {
    $hash = Password::hash('somepassword', ['cost' => 20]);
    // save...
}
```
