/*
 * Created by hongbo.he@lnxall.com
 *
 * 2025/09/01
 */
#ifndef LNXUTILS_STRING_H
#define LNXUTILS_STRING_H

#include <unistd.h>

void lnxutil_str_tolower(char *str, size_t len);

void lnxutil_str_toupper(char *str, size_t len);

/*
 * convertion between hex and string
 */
int lnxutil_i82hexstr(const unsigned char *hex, size_t hexlen,
					  char *outbuf, size_t outlen);

int lnxutil_str2hex(const char *str, size_t slen, unsigned char *outbuf, size_t outlen);

/*
 * the safe version of `get_ip`
 *  convert '192.168.22.104' to byte-array: [192, 168, 22, 104]
 */
void lnxutil_string_to_ipv4addr(unsigned char ipv4[4], const char *ipv4str);

int lnxutil_replace_substr(const char *str, const char *sub_src, const char *sub_dst,
						   char *outbuf, size_t outlen);

int lnxall_encrypt_string(unsigned char *in, int len, unsigned char *out);

int lnxall_decrypt_string(unsigned char *in, int len, unsigned char *out);

#endif
