javacommons/utils/src/javacommonutils.cpp
changeset 76 4ad59aaee882
parent 61 bf7ee68962da
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
   283     BIO_get_mem_ptr(b64, &bptr);
   283     BIO_get_mem_ptr(b64, &bptr);
   284 
   284 
   285     std::string result;
   285     std::string result;
   286     result.insert(0, bptr->data, bptr->length);
   286     result.insert(0, bptr->data, bptr->length);
   287     BIO_free_all(b64);
   287     BIO_free_all(b64);
   288 
   288     CRYPTO_cleanup_all_ex_data();
       
   289     
   289     return result;
   290     return result;
   290 }
   291 }
   291 
   292 
   292 OS_EXPORT std::wstring JavaCommonUtils::wbase64encode(const std::wstring& aData)
   293 OS_EXPORT std::wstring JavaCommonUtils::wbase64encode(const std::wstring& aData)
   293 {
   294 {
   311     for (int i = 0; i < bptr->length; i++)
   312     for (int i = 0; i < bptr->length; i++)
   312     {
   313     {
   313         result.push_back((wchar_t)*(bptr->data + i));
   314         result.push_back((wchar_t)*(bptr->data + i));
   314     }
   315     }
   315     BIO_free_all(b64);
   316     BIO_free_all(b64);
   316 
   317     CRYPTO_cleanup_all_ex_data();
       
   318     
   317     return result;
   319     return result;
   318 }
   320 }
   319 
   321 
   320 OS_EXPORT std::string JavaCommonUtils::base64decode(const std::string& aData)
   322 OS_EXPORT std::string JavaCommonUtils::base64decode(const std::string& aData)
   321 {
   323 {
   336     std::string result;
   338     std::string result;
   337     result.insert(0, buf, olen);
   339     result.insert(0, buf, olen);
   338 
   340 
   339     BIO_free_all(bmem);
   341     BIO_free_all(bmem);
   340     delete[] buf;
   342     delete[] buf;
   341 
   343     CRYPTO_cleanup_all_ex_data();
       
   344     
   342     return result;
   345     return result;
   343 }
   346 }
   344 
   347 
   345 OS_EXPORT std::wstring JavaCommonUtils::percentDecode(const std::wstring& str)
   348 OS_EXPORT std::wstring JavaCommonUtils::percentDecode(const std::wstring& str)
   346 {
   349 {