// SimpleCrypt.cpp : Implementation of CSimpleCrypt #include "stdafx.h" #include "Crypto.h" #include "SimpleCrypt.h" ///////////////////////////////////////////////////////////////////////////// // CSimpleCrypt ///////////////////////////////////////////////////////////////////////////// STDMETHODIMP CSimpleCrypt::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = {&IID_ISimpleCrypt,}; for (int i=0;i dwDataLen*2 ) return FALSE; for (i=0, j=0; i < bstrHexRep.Length(); j++, i=i+2) { hi=(BYTE)bstrHexRep[i]; if(!ToBinary(hi)) return FALSE; lo=(BYTE)bstrHexRep[i+1]; if(!ToBinary(lo)) return FALSE; pbData[j] = (hi<<4) + lo; } return TRUE; } ///////////////////////////// BOOL CSimpleCrypt::ToBinary(BYTE& hexVal) { if (hexVal >='0' && hexVal <='9') hexVal=hexVal-'0'; else if (hexVal >='a' && hexVal <='f') hexVal=hexVal-'a'+10; else if (hexVal >='A' && hexVal <='F') hexVal=hexVal-'A'+10; else return FALSE; return TRUE; }