MD5 in Nginx

core/ngx_md5.h header file

/* * Copyright (C) Igor Sysoev * Copyright (C) Nginx , Inc. */#ifndef _NGX_MD5_H_INCLUDED_#define _NGX_MD5_H_INCLUDED_#include #include #if (NGX_HAVE_MD5)#if (NGX_HAVE_OPENSSL_MD5_H)#include  #endiftypedef MD5_CTX ngx_md5_t; #if (NGX_OPENSSL_MD5) #define ngx_md5_init MD5_Init # define ngx_md5_update MD5_Update # define ngx_md5_final MD5_Final # else # define ngx_md5_init MD5Init # define ngx_md5_update MD5Update # define ngx_md5_final MD5Final # endif # else / * NGX_HAVE_MD5 * / typedef! struct {uint64_t bytes; uint32_t a, b, c, d; u_char buffer[64];} ngx_md5_t;void ngx_md5_init(ngx_md5_t *ctx);void ngx_md5_update(ngx_md5_t *ctx, ngx_md5_t *5 u_char result[16], ngx_md5_t *ctx);#endif#endif /* _NGX_MD5_H_INCLUDED_ */

Invoke step

ngx_md5_init(ngx_md5_t *ctx);//Update ctxn to data with a length of size gx_md5_update(ngx_md5_t *ctx, const void *data, size_t size);//Generate a 16-byte md5 value ngx_md5_final(u_char result[16], ngx_md5_t *ctx);

Example

static int calculate_md5(ngx_str_t *str){ ngx_md5_t md5; int i; char md5_buf[16], md5_buf2[32], buf[1024]; if (str->len <= 0 || str->len> sizeof(buf)) {return -1;} memcpy(buf, str->data, str->len); ngx_md5_init(&md5); ngx_md5_update(&md5, buf, str-> len); ngx_md5_final(md5_buf, &md5); //The md5_buf obtained here is a 16-byte md5 value, which can be converted into a 32-byte for (i = 0; i <16; i++){ sprintf(md5_buf2 + i* 2, "%02X", md5_buf[i]);} return 0;}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4627 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.