openharmony 鸿蒙 capi-crypto-digest-h

2026-08-25 浏览 (1)

crypto_digest.h

Overview

Defines APIs for MD algorithms.

Header file: <CryptoArchitectureKit/crypto_digest.h>

Library: libohcrypto.so

System capability: SystemCapability.Security.CryptoFramework

Since: 12

Related module: CryptoDigestApi

Summary

Structs

Nametypedef KeywordDescription
OH_CryptoDigestOH_CryptoDigestDefines an MD.

Functions

NameDescription
OH_Crypto_ErrCode OH_CryptoDigest_Create(const char *algoName, OH_CryptoDigest **ctx)Creates an MD instance based on the given algorithm name.
Note: The created resource must be destroyed by calling OH_DigestCrypto_Destroy.
OH_Crypto_ErrCode OH_CryptoDigest_Update(OH_CryptoDigest *ctx, Crypto_DataBlob *in)Updates MD data.
OH_Crypto_ErrCode OH_CryptoDigest_Final(OH_CryptoDigest *ctx, Crypto_DataBlob *out)Implements MD calculation.
Note: After the use is complete, the memory for storing the out parameter must be released by calling OH_Crypto_FreeDataBlob.
uint32_t OH_CryptoDigest_GetLength(OH_CryptoDigest *ctx)Obtains the length of an MD.
const char *OH_CryptoDigest_GetAlgoName(OH_CryptoDigest *ctx)Obtains the name of an MD algorithm.
void OH_DigestCrypto_Destroy(OH_CryptoDigest *ctx)Destroys an MD instance.

Function Description

OH_CryptoDigest_Create()

OH_Crypto_ErrCode OH_CryptoDigest_Create(const char *algoName, OH_CryptoDigest **ctx)

Description

Creates an MD instance based on the given algorithm name.
Note: The created resource must be destroyed by calling OH_DigestCrypto_Destroy.

Since: 12

Parameters

NameDescription
const char *algoNamePointer to the algorithm used to generate the MD instance.
For example, SHA256.
OH_CryptoDigest **ctxPointer to the MD instance created.

Returns

TypeDescription
OH_Crypto_ErrCodeCRYPTO_SUCCESS: The operation is successful.
CRYPTO_INVALID_PARAMS: A parameter is invalid.
CRYPTO_NOT_SUPPORTED: The operation is not supported.
CRYPTO_MEMORY_ERROR: A memory error occurs.
CRYPTO_OPERTION_ERROR: Failed to call an API of a third-party algorithm library.

OH_CryptoDigest_Update()

OH_Crypto_ErrCode OH_CryptoDigest_Update(OH_CryptoDigest *ctx, Crypto_DataBlob *in)

Description

Updates MD data.

Since: 12

Parameters

NameDescription
OH_CryptoDigest *ctxPointer to the MD instance.
Crypto_DataBlob *inPointer to the data to pass in.

Returns

TypeDescription
OH_Crypto_ErrCodeCRYPTO_SUCCESS: The operation is successful.
CRYPTO_INVALID_PARAMS: A parameter is invalid.
CRYPTO_NOT_SUPPORTED: The operation is not supported.
CRYPTO_MEMORY_ERROR: A memory error occurs.
CRYPTO_OPERTION_ERROR: Failed to call an API of a third-party algorithm library.

See also

OH_CryptoDigest_Final

OH_CryptoDigest_Final()

OH_Crypto_ErrCode OH_CryptoDigest_Final(OH_CryptoDigest *ctx, Crypto_DataBlob *out)

Description

Implements MD calculation.
Note: After the use is complete, the memory for storing the out parameter must be released by calling OH_Crypto_FreeDataBlob.

Since: 12

Parameters

NameDescription
OH_CryptoDigest *ctxPointer to the MD instance.
Crypto_DataBlob *outPointer to the MD generated.

Returns

TypeDescription
OH_Crypto_ErrCodeCRYPTO_SUCCESS: The operation is successful.
CRYPTO_INVALID_PARAMS: A parameter is invalid.
CRYPTO_NOT_SUPPORTED: The operation is not supported.
CRYPTO_MEMORY_ERROR: A memory error occurs.
CRYPTO_OPERTION_ERROR: Failed to call an API of a third-party algorithm library.

See also

OH_CryptoDigest_Update

OH_CryptoDigest_GetLength()

uint32_t OH_CryptoDigest_GetLength(OH_CryptoDigest *ctx)

Description

Obtains the length of an MD.

Since: 12

Parameters

NameDescription
OH_CryptoDigest *ctxPointer to the MD instance.

Returns

TypeDescription
uint32_tMD length.
If the input parameter ctx is NULL, 401 is returned. In other cases, 0 is returned.

OH_CryptoDigest_GetAlgoName()

const char *OH_CryptoDigest_GetAlgoName(OH_CryptoDigest *ctx)

Description

Obtains the name of an MD algorithm.

Since: 12

Parameters

NameDescription
OH_CryptoDigest *ctxPointer to the MD instance.

Returns

TypeDescription
const char *MD algorithm name.

OH_DigestCrypto_Destroy()

void OH_DigestCrypto_Destroy(OH_CryptoDigest *ctx)

Description

Destroys an MD instance.

Since: 12

Parameters

NameDescription
OH_CryptoDigest *ctxPointer to the MD instance.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-cryptosymkeyapi-oh-cryptosymkey

openharmony 鸿蒙 capi-cryptoasymkeyapi-oh-cryptoasymkeygeneratorwithspec

openharmony 鸿蒙 capi-cryptoasymcipherapi-oh-cryptoasymcipher

openharmony 鸿蒙 capi-cryptokdfapi-oh-cryptokdfparams

openharmony 鸿蒙 capi-cryptomacapi

openharmony 鸿蒙 capi-cryptodigestapi-oh-cryptodigest

openharmony 鸿蒙 capi-cryptomacapi-oh-cryptomac

openharmony 鸿蒙 capi-cryptosignatureapi-oh-cryptoeccsignaturespec

openharmony 鸿蒙 capi-cryptocommonapi-crypto-datablob

openharmony 鸿蒙 capi-cryptoasymcipherapi-oh-cryptosm2ciphertextspec

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/xHRPZpX9