![]() ![]() ![]()
|
SophiaFramework UNIVERSE 5.3 |

| BREW 2.0 | BREW 2.1 | BREW 3.1 | BREW 4.0 |
|---|---|---|---|
| O | O | O | O |
| Public Functions | |
|---|---|
| SFCError |
GetResult(
VoidPtr data
, SInt32Ptr size
)
Get the hashed result after all the calls to SFBHash::Update().
|
| SFCError |
GetResult(
SFXBufferPtr data
)
Get the hashed result after all the calls to SFBHash::Update().
|
| static SFBHashSmp |
NewInstance(
AEECLSID clsid = AEECLSID_MD5
, SFCErrorPtr exception = null
) Create a new SFBHash instance.
|
| Void |
Restart( Void )
Start a new hash.
|
| SFCError |
SetKey(
VoidConstPtr key
, SInt32 keySize
)
Initializes key for HMAC keyed hashes.
|
| SFCError |
SetKey(
SFXBufferConstRef key
)
Initializes key for HMAC keyed hashes.
|
| Void |
Update(
VoidPtr data
, SInt32 dataLength
)
Feed data to the hash object.
|
| Void |
Update(
SFXBufferPtr data
)
Feed data to the hash object.
|
| Protected Functions | |
|---|---|
| static SFBBaseSmp |
FactoryByCreate(
AEECLSID id
, SFCErrorPtr exception = null
)
(inherits from SFBBase)
Create the instance for the specified ClassID's interface.
|
| static SFBBaseSmp |
FactoryByQuery(
SFBQuerySmpConstRef query
, AEECLSID id
, SFCErrorPtr exception = null
)
(inherits from SFBBase)
Create the instance for the specified ClassID's interface using the SFBQuery instance.
|
[ 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 for the Hash algorithm SFCErrorPtr exception = null // Error );
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 SFBHash instance.
SFBHashSmp hash = SFBHash::NewInstance();
// hash.
hash->Update(srcString, STRLEN(srcString));
// get the result.
hash->GetResult(result, &len);
// show the results 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 results in log.
DBGPRINTF("*** next result: %s ***", result);
[ public ] SFCError SetKey( VoidConstPtr key // Pointer to key SInt32 keySize // key size in bytes );
[ public ] SFCError SetKey( SFXBufferConstRef key // Pointer to key );
Introduced in BREW 3.1
![]() |
Caution |
|---|---|
Calling this function on earlier versions of BREW 3.1 will cause your app to crash. | |
[ 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 results 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 - 2012 Sophia Cradle Incorporated All Rights Reserved. |
![]() ![]() ![]()
|