MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / GetPathHash

Function GetPathHash

libcppcryptfs/util/util.cpp:619–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

617
618
619BOOL GetPathHash(LPCWSTR path, wstring& hashstr)
620{
621
622 hashstr = L"";
623
624 wstring ucpath;
625
626 if (!touppercase(path, ucpath))
627 return FALSE;
628
629 size_t len = ucpath.length();
630
631 while (len > 3) {
632
633 if (ucpath[len - 1] == '\\') {
634 ucpath.resize(len - 1);
635 } else {
636 break;
637 }
638 len = ucpath.length();
639 }
640
641 if (len < 1)
642 return FALSE;
643
644 path = ucpath.c_str();
645
646 string str;
647
648 if (!unicode_to_utf8(path, str))
649 return FALSE;
650
651 BYTE sum[32];
652
653 if (!sha256(str, sum))
654 return FALSE;
655
656 int i;
657
658 // use only 128bits of the sha256 to keep registry key length shorter
659
660 for (i = 0; i < 16; i++) {
661 WCHAR buf[3];
662 swprintf_s(buf, L"%02x", sum[i]);
663 hashstr += buf;
664 }
665
666 return TRUE;
667}
668
669void SetOverlapped(LPOVERLAPPED pOv, LONGLONG offset)
670{

Callers 6

SavePasswordMethod · 0.85
RetrievePasswordMethod · 0.85
CreateCryptfsMethod · 0.85
MountMethod · 0.85
OnSetActiveMethod · 0.85
OnCbnSelchangePathMethod · 0.85

Calls 3

touppercaseFunction · 0.85
unicode_to_utf8Function · 0.85
sha256Function · 0.85

Tested by

no test coverage detected