# 암/복호화

## ![](/files/kVVDmuZUV6tIYNEijhbm)

## 대칭키(AES) 암호화&#x20;

AES (Advanced Encryption Standard)는 대칭키 암호화 알고리즘으로, 동일한 키를 사용하여 데이터를 암호화 및 복호화합니다.&#x20;

```dart
final key = encrypt.Key.fromSecureRandom(32);
final iv = encrypt.IV.fromSecureRandom(16);

final encrypter = encrypt.Encrypter(encrypt.AES(key));
final encrypted = encrypter.encrypt(plainText, iv: iv);
final decrypted = encrypter.decrypt(encrypted, iv: iv);
```

위 코드는 Flutter에서 AES 암호화를 어떻게 수행하는지 보여줍니다. AES 암호화를 위해 암호화 키와 초기화 벡터(IV)를 생성하고, 이를 사용하여 평문을 암호화하고 복호화합니다.

#### 결과

![](/files/Zx9wczYSVKaGzfpMaDDC)

\
비대칭키(RSA) 암호화
-------------

RSA (Rivest–Shamir–Adleman)는 비대칭키 암호화 알고리즘으로, 공개키와 개인키를 사용하여 데이터를 암호화 및 복호화합니다.&#x20;

```dart
final publicPem = await rootBundle.loadString('assets/pem/public.pem');
final publicKey = RSAKeyParser().parse(publicPem) as RSAPublicKey;

final privatePem = await rootBundle.loadString('assets/pem/private.pem');
final privKey = RSAKeyParser().parse(privatePem) as RSAPrivateKey;

final encrypter = encrypt.Encrypter(
    encrypt.RSA(publicKey: publicKey, privateKey: privKey));

final encrypted = encrypter.encrypt(plainText);
final decrypted = encrypter.decrypt(encrypted);
```

위 코드는 Flutter에서 RSA 암호화를 어떻게 수행하는지 보여줍니다. RSA 암호화를 위해 공개 키와 개인 키를 사용하고, 이를 사용하여 평문을 암호화하고 복호화합니다.

#### 결과

![](/files/7AoDRuKxXAGWQphacXsv)


---

# 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://developer.aliothx.net/start/security/index/en-decoding.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.
