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
- idb2pat
- javascript
- why error
- ida
- commandline
- Python
- Injection
- debugging
- idapython
- h5py.File
- idapro
- Ransomware
- open office xml
- svn update
- MySQL
- x64
- data distribution
- Rat
- pytest
- 포인터 매핑
- hex-rays
- malware
- NumPy Unicode Error
- ecma
- error fix
- Analysis
- mock.patch
- ida pro
- TensorFlow
- error
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