
Sodium_crypto_auth_verify 함수는 데이터의 인증을 위해 사용됩니다. 이 함수의 매개변수는 3개로 구성되며, key, message, tag입니다.
- key: 인증을 위한 비밀키입니다. 이 키는 Sodium_crypto_auth 함수에서 생성한 키와 동일해야 합니다.
- message: 인증을 원하는 데이터입니다.
- tag: Sodium_crypto_auth 함수에서 생성한 인증 태그입니다.
이 함수의 반환값은 1이면 인증이 성공적으로 완료되었고, 0이면 인증이 실패한 것입니다.
인증을 진행하기 전에, Sodium_crypto_auth 함수를 통해 인증 태그를 생성해야 합니다.
#hostingforum.kr
c
#include
// 인증 태그를 생성하기 위한 비밀키
unsigned char key[32];
// 인증을 원하는 데이터
unsigned char message[32];
// 생성된 인증 태그
unsigned char tag[32];
// 인증 태그를 생성
sodium_crypto_auth(key, message, 32, tag);
// 인증을 확인
int result = sodium_crypto_auth_verify(key, message, 32, tag);
if (result == 1) {
printf("인증이 성공적으로 완료되었습니다.n");
} else {
printf("인증이 실패했습니다.n");
}
위의 예제에서, key는 32바이트의 비밀키를 의미하며, message는 32바이트의 데이터를 의미합니다. tag는 생성된 인증 태그를 의미합니다.
Sodium_crypto_auth_verify 함수를 호출할 때, key, message, tag의 값을 정확하게 전달해야 합니다.
#hostingforum.kr
c
int sodium_crypto_auth_verify(const unsigned char *key, const unsigned char *message, size_t message_length, const unsigned char *tag);
위의 함수는 key, message, tag의 값을 전달받아, 인증을 확인하고 1 또는 0을 반환합니다.
인증을 확인하기 전에, Sodium_crypto_auth 함수를 통해 인증 태그를 생성해야 합니다.
#hostingforum.kr
c
int sodium_crypto_auth(const unsigned char *key, const unsigned char *message, size_t message_length, unsigned char *tag);
위의 함수는 key, message, tag의 값을 전달받아, 인증 태그를 생성합니다.
인증 태그를 생성한 후, Sodium_crypto_auth_verify 함수를 호출하여 인증을 확인할 수 있습니다.
#hostingforum.kr
c
int result = sodium_crypto_auth_verify(key, message, 32, tag);
if (result == 1) {
printf("인증이 성공적으로 완료되었습니다.n");
} else {
printf("인증이 실패했습니다.n");
}
2025-05-04 05:56