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 ); }
  • 相关阅读:
    zoj_3710Friends
    javamail例子
    HttpURLConnection类的用法
    发送邮件协议
    栈的定义
    tomcat中添加jconsole服务
    HttpURLConnection类的用法
    javamail例子
    tomcat中添加jconsole服务
    栈的定义
  • 原文地址:https://www.cnblogs.com/praiseslow/p/15720177.html
Copyright © 2011-2022 走看看