Add SHA-1 hash feature

Fix #13791, close #13792
This commit is contained in:
Don Ho 2023-06-17 03:58:56 +02:00
parent 51bddf57ad
commit b883759c83
7 changed files with 49 additions and 17 deletions

View File

@ -17,7 +17,7 @@
#include "md5.h"
#include <stdint.h>
#include "sha-256.h"
#include "cal_sha1.h"
#include "calc_sha1.h"
#include "md5Dlgs.h"
#include "md5Dlgs_rc.h"
#include "CustomFileDialog.h"

View File

@ -1,10 +0,0 @@
#include "cal_sha1.h"
#include "sha1.h"
void calc_sha1(unsigned char hash[20], const void *input, size_t len)
{
CSHA1 sha1;
sha1.Update((const uint8_t*)input, static_cast<unsigned int>(len));
sha1.Final();
sha1.GetHash(hash);
}

View File

@ -1,3 +0,0 @@
#pragma once
void calc_sha1(unsigned char hash[20], const void *input, size_t len);

View File

@ -0,0 +1,26 @@
// This file is part of Notepad++ project
// Copyright (C)2023 Don HO <don.h@free.fr>
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include "calc_sha1.h"
#include "sha1.h"
void calc_sha1(unsigned char hash[20], const void *input, size_t len)
{
CSHA1 sha1;
sha1.Update((const uint8_t*)input, static_cast<unsigned int>(len));
sha1.Final();
sha1.GetHash(hash);
}

View File

@ -0,0 +1,19 @@
// This file is part of Notepad++ project
// Copyright (C)2023 Don HO <don.h@free.fr>
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
void calc_sha1(unsigned char hash[20], const void *input, size_t len);

View File

@ -33,7 +33,7 @@
#include "verifySignedfile.h"
#include "md5.h"
#include "sha-256.h"
#include "cal_sha1.h"
#include "calc_sha1.h"
using namespace std;

View File

@ -127,7 +127,7 @@
<ClCompile Include="..\src\DarkMode\DarkMode.cpp" />
<ClCompile Include="..\src\MISC\Common\verifySignedfile.cpp" />
<ClCompile Include="..\src\MISC\md5\md5Dlgs.cpp" />
<ClCompile Include="..\src\MISC\sha1\cal_sha1.cpp" />
<ClCompile Include="..\src\MISC\sha1\calc_sha1.cpp" />
<ClCompile Include="..\src\MISC\sha1\sha1.cpp" />
<ClCompile Include="..\src\MISC\sha2\sha-256.cpp" />
<ClCompile Include="..\src\NppDarkMode.cpp" />
@ -266,7 +266,7 @@
<ClInclude Include="..\src\MISC\md5\md5.h" />
<ClInclude Include="..\src\MISC\md5\md5Dlgs.h" />
<ClInclude Include="..\src\MISC\md5\md5Dlgs_rc.h" />
<ClInclude Include="..\src\MISC\sha1\cal_sha1.h" />
<ClInclude Include="..\src\MISC\sha1\calc_sha1.h" />
<ClInclude Include="..\src\MISC\sha1\sha1.h" />
<ClInclude Include="..\src\MISC\sha2\sha-256.h" />
<ClInclude Include="..\src\NppDarkMode.h" />