
암호화가 실패하는 이유는 `crypto_aead_aes256gcm_encrypt` 함수의 마지막 두 개의 인자인 `additional_data`와 `additional_data_len`가 NULL과 0으로 설정되어 있기 때문입니다.
이 함수는 암호화할 데이터에 추가 데이터를 포함할 수 있는 기능을 제공하며, 이 추가 데이터는 암호화 프로세스에 포함됩니다.
하지만 이 경우, 추가 데이터가 없으므로 NULL과 0을 전달하는 것은 의미가 없습니다.
따라서, 추가 데이터가 없을 때는 NULL과 0 대신 NULL을 전달하는 것이 좋습니다.
정확한 코드는 다음과 같습니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
#hostingforum.kr
c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %dn", crypto_aead_aes256gcm_last_error());
}
위 코드는 다음과 같이 수정되어야 합니다.
```c
if (crypto_aead_aes256gcm_encrypt(ciphertext, plaintext, plaintext_len, nonce, key, NULL, 0) != 0) {
printf("Error: %d\n
2025-07-11 17:50