![]() ![]() ![]()
|
BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1 |

| BREW 2.0 | BREW 2.1 | BREW 3.1 |
|---|---|---|
| O | O | O |
| Public Functions | |
|---|---|
| SFCError |
GetResult(
VoidPtr data
, SInt32Ptr size
) GetResult( SFXBufferPtr data )
Get the hashed result after all the calls to SFBHash::Update().
|
| static SFBHashSmp |
NewInstance(
AEECLSID clsid = AEECLSID_MD5
) Create a new instance of SFBHash class.
|
| Void |
Restart( Void )
Start a new hash.
|
| Void |
Update(
VoidPtr data
, SInt32 dataLength
) Update( SFXBufferPtr data )
Feed data to the hash object.
|
[ public ] SFCError GetResult( VoidPtr data // pointer to the data to get the hashed result SInt32Ptr size // pointer to the size of the buffer pbData. // on return, this contains the size of the hashed result );
[ public ] SFCError GetResult( SFXBufferPtr data // pointer to the data to get the hashed result. // the size of the buffer can be modified automatically );
Warning: Buffer size can not over the limit of a SInt32 value.
[ public, static ] SFBHashSmp NewInstance( AEECLSID clsid = AEECLSID_MD5 // ClassID of Hash algorithm );
The available ClassID is as below.
| AEECLSID_MD2 |
| AEECLSID_MD5 |
| AEECLSID_SHA1 |
[ public ] Void Restart(Void);
New data stream needs to be hashed.
Hash different data streams continuously, and show the log.
AChar srcString[] = {"message for you..."};
AChar srcStringNext[] = {"next message for you..."};
AChar result[32] = {0};
SInt32 len = 32;
// create new instance of SFBHash class.
SFBHashSmp hash = SFBHash::NewInstance();
// hash.
hash->Update(srcString, STRLEN(srcString));
// get the resault.
hash->GetResult(result, &len);
// show the resaults in log.
DBGPRINTF("*** result: %s ***", result);
// hash again.
ZEROAT(result);
len = 32;
// reset the data stream.
hash->Restart();
// hash byte by byte.
ACharPtr i = srcStringNext;
for (; *i; i++)
hash->Update(i, 1);
// get the result.
hash->GetResult(result, &len);
// show the resaults in log.
DBGPRINTF("*** next result: %s ***", result);
[ public ] Void Update( VoidPtr data // pointer to the data to be hashed SInt32 dataLength // length of the data to be hashed(stored in data) );
[ public ] Void Update( SFXBufferPtr data // pointer to the data to be hashed. // if null, do nothing );
This function can be called multiple times to hash long streams or discontinous streams of data.
Hash a stream, show resaults in log.
AChar srcString[] = {"message for you..."};
AChar result[32] = {0};
SInt32 len = 32;
// create new instance of SFBHash cLass.
SFBHashSmp hash = SFBHash::NewInstance();
// hash.
hash->Update(srcString, STRLEN(srcString));
// get the result.
hash->GetResult(result, &len);
// show the result in log.
DBGPRINTF("*** result: %s ***", result);
|
Copyright (C) 2002 - 2008 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|