
`sodium_crypto_aead_aegis128l_decrypt` 함수는 AEAD(Authenticated Encryption with Associated Data) 방식의 복호화 함수입니다. 매개 변수는 다음과 같습니다.
- `m`: 복호화할 메시지
- `m_len`: 메시지의 길이
- `ad`: 연관 데이터
- `ad_len`: 연관 데이터의 길이
- `npub`: 공유 키를 생성한 후에 공유 키를 사용하여 생성한 nonce의 공유 키
- `ciphertext`: 암호화된 메시지
- `ciphertext_len`: 암호화된 메시지의 길이
- `key`: 공유 키
- `nonce`: nonce
위 코드에서 `sodium_crypto_aead_aegis128l_decrypt` 함수의 매개 변수를 정확히 무엇을 넣어야 하는지 알려드리겠습니다.
#hostingforum.kr
c
int key[32]; // 공유 키
unsigned char nonce[12]; // nonce
unsigned char message[1024]; // 복호화할 메시지
unsigned char decrypted[1024]; // 복호화된 메시지
unsigned char ad[0]; // 연관 데이터 (이 예제에서는 사용하지 않음)
unsigned char ciphertext[1024]; // 암호화된 메시지
sodium_init(); // Sodium 라이브러리 초기화
// 키 생성
sodium_crypto_secretbox_keygen(key);
// nonce 생성
sodium_randombytes_buf(nonce, 12);
// 암호화
unsigned char tag[16];
unsigned char ciphertext_len = 1024;
sodium_crypto_aead_aegis128l_encrypt(NULL, NULL, NULL, NULL, tag, ciphertext, ciphertext_len, message, 1024, nonce, key);
// 복호화
unsigned char decrypted_len = 1024;
sodium_crypto_aead_aegis128l_decrypt(decrypted, NULL, NULL, NULL, NULL, tag, ciphertext, ciphertext_len, message, 1024, nonce, key);
위 코드에서 `sodium_crypto_aead_aegis128l_decrypt` 함수의 매개 변수를 정확히 무엇을 넣어야 하는지 알려드렸습니다.
2025-06-14 20:14