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