SophiaFramework UNIVERSE 5.3 |
BREW 2.0 | BREW 2.1 | BREW 3.1 | BREW 4.0 |
---|---|---|---|
O | O | O | O |
Public Functions | |
---|---|
SInt32 |
Cipher(
VoidConstPtr data
, SInt32 dataSize
, VoidPtr result
, SInt32Ptr resultSize
)
Encrypt or decrypt data using the key previously initialized.
|
SInt32 |
Cipher(
SFXBufferConstRef data
, SFXBufferPtr buffer
)
Encrypt or decrypt data using the key previously initialized.
|
Void |
Flush( Void )
Use with block ciphers during the encryption process to pad
the last unprocessed block with predetermined bytes to form
a complete block. This function does nothing if the block is
already complete (64-bits in DES).
|
SFCError |
Init(
VoidConstPtr key
, SInt32 keySize
)
Initializes the key for encryption or decryption using ArcFour.
|
SFCError |
Init(
SFXBufferConstRef key
)
Initializes the key for encryption or decryption using ArcFour.
|
static SFBCipherSmp |
NewInstance(
AEECLSID clsid
, SFCErrorPtr exception = null
)
Create a new SFBCipher instance.
|
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 ] SInt32 Cipher( VoidConstPtr data // pointer to data to be encrypted/decrypted SInt32 dataSize // input data size in bytes VoidPtr result // buffer to receive encrypted/decrypted data SInt32Ptr resultSize // size of output in bytes );
[ public ] SInt32 Cipher( SFXBufferConstRef data // pointer to data to be encrypted/decrypted SFXBufferPtr buffer // buffer to receive encrypted/decrypted data. // buffer size is set to SInt32 when call );
Encrypt/Decrypt data by common key.
// deside the key for Encrypting/Decrypting char key[] = {"Key Cipher"}; SInt32 keySize = STRLEN(key); // create Interface of SFBCipher // encrypt data by ArcFour (RC4 interconverting). SFBCipherSmp cipher = SFBCipher::NewInstance(AEECLSID_ARC4); // set Decrypted key if (SUCCESS == cipher->Init(key, keySize)) { SFXAnsiString srcData("Cipher"); SInt32 size = src_data.GetLength() + 1; VoidPtr encData = MALLOC(size); VoidPtr decData = MALLOC(size); // output the un-Decrypted data DBGPRINTF("srcData -- %s", srcData.GetBuffer()); // decrypt it cipher->Cipher(srcData.GetBuffer(), size, encData, &size); // output the Decrypted data DBGPRINTF("encData -- %s", (char*)encData); // set Decrypted key cipher->Init(key, keySize); // decrypt it cipher->Cipher(encData, size, decData, &size); // output the Decrypted data DBGPRINTF("decData -- %s", (char*)decData); // release Buffer. FREE(encData); FREE(decData); }
[ public ] Void Flush(Void);
Tip | |
---|---|
Before BREW SDK 2.1 , block encryption algorithm is not supported in ICipher Interface. So, it is not necessary tu use this function. |
[ public ] SFCError Init( VoidConstPtr key // pointer to key SInt32 keySize // key size in bytes );
[ public ] SFCError Init( SFXBufferConstRef key // pointer to key );
[ public, static ] SFBCipherSmp NewInstance( AEECLSID clsid // ClassID for the encrypted interface SFCErrorPtr exception = null // Error );
Create an encrypted interface, return it as ICipher. ClassID can be specified as below. Homologous algorithm will be used for specified ClassID.
AEECLSID_ARC4 |
AEECLSID_DES_ENCRYPT |
AEECLSID_DES_DECRYPT |
AEECLSID_3DES_ENCRYPT |
AEECLSID_3DES_DECRYPT |
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |