国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

windows API CryptBinaryToString

2019-11-09 20:20:29
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
// windowsapi 直接調(diào)用的base64編碼解碼函數(shù)// #include <windows.h>  #include <Wincrypt.h>  #PRagma comment(lib,"crypt32")  #include "base64.h"  using namespace gloox;  static unsigned long get_file_size(const char *path)  {      unsigned long filesize = -1;      FILE *fp;      fp = fopen(path, "r");      if(fp == NULL)          return filesize;      fseek(fp, 0L, SEEK_END);      filesize = ftell(fp);      fclose(fp);      return filesize;  }  int _tmain(int argc, _TCHAR* argv[])  {      const char path[] = "silence.png";      ULONG uSize = get_file_size(path);      FILE* fp = fopen(path, "rb");      char* inBuffer = new char[uSize];      ULONG uReaded = fread(inBuffer, 1, uSize, fp);      const BYTE* pbBinary = (const BYTE*)inBuffer;      DWord dwLen;      CryptBinaryToStringA(pbBinary, uSize, CRYPT_STRING_BASE64, NULL, &dwLen);   //把二進(jìn)制序列轉(zhuǎn)換成字符串    char* pCrypt1 = new char[dwLen];      CryptBinaryToStringA(pbBinary, uSize, CRYPT_STRING_BASE64, pCrypt1, &dwLen);//把二進(jìn)制序列轉(zhuǎn)換成字符串    fclose(fp);      std::string strIn(pCrypt1);      int nIn = strIn.length();      std::string strOut = Base64::encode64(strIn);      int nOut = strOut.length();      //////////////////////////////////////////////////////////////      std::string strFile = Base64::decode64(strOut);      int nFile = strFile.length();      int nFileSize = strFile.size();      DWORD cbBinary;      DWORD dwSkip;      DWORD dwFlags;      CryptStringToBinaryA(strFile.data(), nFile+1, CRYPT_STRING_BASE64, NULL, &cbBinary, &dwSkip, &dwFlags);      BYTE* outBuffer = new BYTE[cbBinary];      CryptStringToBinaryA(strFile.data(), nFile+1, CRYPT_STRING_BASE64, outBuffer, &cbBinary, &dwSkip, &dwFlags);      FILE* fp2 = fopen("silence2.png", "wb");      ULONG uWrite = fwrite(outBuffer, 1, uSize, fp2);      fclose(fp2);      return 0;  }  
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 麻江县| 博野县| 惠安县| 巴中市| 扎囊县| 百色市| 醴陵市| 车致| 大庆市| 三明市| 滕州市| 荔浦县| 霍山县| 仪征市| 托克托县| 桐城市| 托克逊县| 阿巴嘎旗| 武安市| 德昌县| 青冈县| 通渭县| 丰镇市| 铜鼓县| 博白县| 乐陵市| 阳东县| 永和县| 白山市| 桐乡市| 农安县| 丰县| 滁州市| 平安县| 石阡县| 元朗区| 石阡县| 雷波县| 枝江市| 驻马店市| 东宁县|