zoukankan      html  css  js  c++  java
  • mbedtls中sha256的使用特性


    /*
    * signv_sha256_calcu calculate the sha256 value upon one continous memory aera, there is no restriction on how many bytes the data are. * The SHA-256 method is a standard and the value can be calculated by mbedtls library. */ int sha256_calcu(const unsigned char *input, size_t len, unsigned char hash_value[]) { int ret = 0; // unsigned char *buf; mbedtls_sha256_context ctx; // buf = mbedtls_calloc( 1024, sizeof(unsigned char) ); mbedtls_sha256_init( &ctx ); do { /* SHA-256 */ if( ( ret = mbedtls_sha256_starts_ret( &ctx, 0 ) ) != 0 ) { mbedtls_sha256_free( &ctx ); // mbedtls_free( buf ); break; } ret = mbedtls_sha256_update_ret( &ctx, input, len); if( ret != 0 ) { mbedtls_sha256_free( &ctx ); // mbedtls_free( buf ); break; } if( ( ret = mbedtls_sha256_finish_ret( &ctx, hash_value ) ) != 0 ) { mbedtls_sha256_free( &ctx ); // mbedtls_free( buf ); break; } mbedtls_sha256_free( &ctx ); // mbedtls_free( buf ); }while(0); return( ret ); }
  • 相关阅读:
    css资料汇总
    typescript 点滴
    vue-cli3点滴
    item2的使用方法推介
    rfc文档
    websocket
    g2
    常用的正则积累
    Vue-20190623点滴
    写一个webpackLoader
  • 原文地址:https://www.cnblogs.com/praiseslow/p/15720177.html
Copyright © 2011-2022 走看看