For educational reasons I've decided to create my own CA. Here is what I learned.
Lets get some context first.
| // Convert a UTF-16 string to an ANSI string. | |
| std::string utf16ToAnsi(const std::wstring &wstr) { | |
| int length = static_cast<int>(wstr.length()); | |
| if (!length) return std::string(); | |
| DWORD flags = WC_NO_BEST_FIT_CHARS; | |
| int bufSize = WideCharToMultiByte(CP_ACP, flags, &wstr[0], length, NULL, 0, NULL, NULL); | |
| if (bufSize > 0) { | |
| std::string strTo(bufSize, 0); | |
| WideCharToMultiByte(CP_ACP, flags, &wstr[0], length, &strTo[0], bufSize, NULL, NULL); |
| #include <windows.h> | |
| #include <time.h> | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| // http://www.programmingforums.org/post45492.html | |
| static const int64_t EPOCH_DIFF = 0x019DB1DED53E8000LL; // 116444736000000000 nsecs | |
| static const int RATE_DIFF = 10000000; // 100 nsecs | |
| time_t tmToUnixTime(const struct tm& stm) { |