Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- Python
- error fix
- x64
- data distribution
- pytest
- idb2pat
- ecma
- hex-rays
- open office xml
- h5py.File
- Ransomware
- TensorFlow
- ida pro
- Rat
- error
- NumPy Unicode Error
- 포인터 매핑
- svn update
- ida
- why error
- idapro
- debugging
- Analysis
- MySQL
- commandline
- javascript
- malware
- idapython
- mock.patch
- Injection
Archives
- Today
- Total
13 Security Lab
Base64(b64) 암호화 복호화 함수 본문
REF. http://www.experts-exchange.com/Programming/Microsoft_Development/A_3216-Fast-Base64-Encode-and-Decode.html
Windows CryptoAPI: CryptBinaryToString and CryptStringToBinary
The Windows CryptoAPI provides a set of general-purpose functions (CryptBinaryToString and CryptStringToBinary) that support base64 encoding and decoding. The following is a pair of functions that wrap that API:
#include#pragma comment (lib, "Crypt32.lib") int ToBase64Crypto( const BYTE* pSrc, int nLenSrc, char* pDst, int nLenDst ) { DWORD nLenOut= nLenDst; BOOL fRet= CryptBinaryToString( (const BYTE*)pSrc, nLenSrc, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, pDst, &nLenOut ); if (!fRet) nLenOut=0; // failed return( nLenOut ); } int FromBase64Crypto( const BYTE* pSrc, int nLenSrc, char* pDst, int nLenDst ) { DWORD nLenOut= nLenDst; BOOL fRet= CryptStringToBinary( (LPCSTR)pSrc, nLenSrc, CRYPT_STRING_BASE64, (BYTE*)pDst, &nLenOut, NULL, // pdwSkip (not needed) NULL // pdwFlags (not needed) ); if (!fRet) nLenOut=0; // failed return( nLenOut ); }
Comments