# 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...
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devcenter-help.nhn-commerce.com/guide/preparation/detailed-structure/security.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
