Skip to content

Commit

Permalink
encode adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
MXWXZ committed Dec 17, 2017
1 parent f5a9bd2 commit 15459d2
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 44 deletions.
2 changes: 2 additions & 0 deletions CryptoLib/CryptoLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ xcopy /r /y "$(TargetPath)" "$(SolutionDir)src\Lib\"</Command>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)CryptoLib\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -153,6 +154,7 @@ xcopy /r /y "$(TargetPath)" "$(SolutionDir)src\Lib\"</Command>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)CryptoLib\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
2 changes: 1 addition & 1 deletion CryptoLib/Include/Hash/sha256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @Author:MXWXZ
* @Date:2017/12/17
*
* @Description:adapted from ºÚèá̶ù http://blog.csdn.net/c_duoduo/article/details/43889759
* @Description:adapted from 黑猫崽儿 http://blog.csdn.net/c_duoduo/article/details/43889759
*/
#include "stdafx.h"
#include "sha256.h"
Expand Down
2 changes: 1 addition & 1 deletion CryptoLib/Include/Hash/sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @Author:MXWXZ
* @Date:2017/12/17
*
* @Description:adapted from ºÚèá̶ù http://blog.csdn.net/c_duoduo/article/details/43889759
* @Description:adapted from 黑猫崽儿 http://blog.csdn.net/c_duoduo/article/details/43889759
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion CryptoLib/Include/Info/disksn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @Author:MXWXZ
* @Date:2017/12/17
*
* @Description:adapted from ³ÂÇïÊ÷ http://blog.sina.com.cn/s/blog_57dff12f0100d5sn.html
* @Description:adapted from chengqiushu http://blog.sina.com.cn/s/blog_57dff12f0100d5sn.html
*/
#include "stdafx.h"
#include "disksn.h"
Expand Down
2 changes: 1 addition & 1 deletion CryptoLib/Include/Info/disksn.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @Author:MXWXZ
* @Date:2017/12/17
*
* @Description:adapted from ³ÂÇïÊ÷ http://blog.sina.com.cn/s/blog_57dff12f0100d5sn.html
* @Description:adapted from chengqiushu http://blog.sina.com.cn/s/blog_57dff12f0100d5sn.html
*/
#pragma once

Expand Down
2 changes: 1 addition & 1 deletion CryptoLib/Include/Utils/stringx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can use
GetA2WLength,GetW2ALength,GetG2ULength,GetU2GLength,GetADataLength or
GetWDataLength to get the length.
Default encoding is GBK£¬if you want to use UTF-8£¬please call SetEncodeUTF8
Default encoding is GBKif you want to use UTF-8please call SetEncodeUTF8
************************************************************************/
#pragma once

Expand Down
72 changes: 35 additions & 37 deletions Demo/Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,60 @@
using namespace CryptoLib;

int main() {
// 注:在IDE中调试时GenerateFile由于路径问题可能会报错,注释或用绝对路径即可
_tsetlocale(LC_ALL, _T("chs"));

_tprintf(_T("CrytoLib库测试(UTF-8编码)\n---------------------------------------\n"));
// 常用哈希
LPTSTR str = _T("abc123中文");
_tprintf(_T(" 常用哈希(测试字符串:abc123中文)\n -----------------------------\n"));
// MD5
_tprintf(_T(" MD5 长度:32\n"));
_tprintf(_T(" MD5值小写:%s\n"), Hash_MD5::Generate(str).GetTString().c_str()); //默认返回小写
_tprintf(_T(" MD5值大写:%s\n"), Hash_MD5::Generate(str).MakeUpper().GetTString().c_str()); //转换成大写
_tprintf(_T(" 本程序MD5:%s\n"), Hash_MD5::GenerateFile(_T("Demo.exe")).GetTString().c_str()); //文件MD5
_tprintf(_T("CrytoLib test(UTF-8)\n---------------------------------------\n"));
// Hash
LPTSTR str = _T("abc?123");
_tprintf(_T(" Hash(test string:abc?123)\n -----------------------------\n"));
// MD5 default is lower
_tprintf(_T(" MD5 length:32\n"));
_tprintf(_T(" MD5 lower:%s\n"), Hash_MD5::Generate(str).GetTString().c_str());
_tprintf(_T(" MD5 upper:%s\n"), Hash_MD5::Generate(str).MakeUpper().GetTString().c_str());
_tprintf(_T(" Program MD5:%s\n"), Hash_MD5::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T("\n"));
// SHA1
_tprintf(_T(" SHA1 长度:40\n"));
_tprintf(_T(" SHA1值:%s\n"), Hash_SHA1::Generate(str).GetTString().c_str());
_tprintf(_T(" 本程序SHA1:%s\n"), Hash_SHA1::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T(" SHA1 length:40\n"));
_tprintf(_T(" SHA1:%s\n"), Hash_SHA1::Generate(str).GetTString().c_str());
_tprintf(_T(" Program SHA1:%s\n"), Hash_SHA1::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T("\n"));
// SHA1
_tprintf(_T(" SHA256 长度:64\n"));
_tprintf(_T(" SHA256值:%s\n"), Hash_SHA256::Generate(str).GetTString().c_str());
_tprintf(_T(" 本程序SHA256:%s\n"), Hash_SHA256::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T(" SHA256 length:64\n"));
_tprintf(_T(" SHA256:%s\n"), Hash_SHA256::Generate(str).GetTString().c_str());
_tprintf(_T(" Program SHA256:%s\n"), Hash_SHA256::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T("\n"));
// SHA1
_tprintf(_T(" SHA512 长度:128\n"));
_tprintf(_T(" SHA512值:%s\n"), Hash_SHA512::Generate(str).GetTString().c_str());
_tprintf(_T(" 本程序SHA512:%s\n"), Hash_SHA512::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T(" SHA512 length:128\n"));
_tprintf(_T(" SHA512:%s\n"), Hash_SHA512::Generate(str).GetTString().c_str());
_tprintf(_T(" Program SHA512:%s\n"), Hash_SHA512::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T("\n"));
// SHA1
_tprintf(_T(" CRC32 长度:8\n"));
_tprintf(_T(" CRC32值:%s\n"), Hash_CRC32::Generate(str).GetTString().c_str());
_tprintf(_T(" 本程序CRC32:%s\n"), Hash_CRC32::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T(" CRC32 length:8\n"));
_tprintf(_T(" CRC32:%s\n"), Hash_CRC32::Generate(str).GetTString().c_str());
_tprintf(_T(" Program CRC32:%s\n"), Hash_CRC32::GenerateFile(_T("Demo.exe")).GetTString().c_str());
_tprintf(_T("\n"));

// 常用加密
_tprintf(_T(" 常用加密(测试字符串:abc123中文)\n -----------------------------\n"));
// encode
_tprintf(_T(" Encode(test string:abc?123)\n -----------------------------\n"));
// Base64
_tprintf(_T(" Base64编码:%s\n"), Encode_Base64::Encode(str).GetTString().c_str());
_tprintf(_T(" Base64解码:%s\n"), Encode_Base64::Decode(Encode_Base64::Encode(str)).GetTString().c_str());
_tprintf(_T(" Base64 encode:%s\n"), Encode_Base64::Encode(str).GetTString().c_str());
_tprintf(_T(" Base64 decode:%s\n"), Encode_Base64::Decode(Encode_Base64::Encode(str)).GetTString().c_str());
_tprintf(_T("\n"));
// UrlEncode
_tprintf(_T(" UrlEncode编码:%s\n"), Encode_UrlEncode::Encode(str).GetTString().c_str());
_tprintf(_T(" UrlEncode解码:%s\n"), Encode_UrlEncode::Decode(Encode_UrlEncode::Encode(str)).GetTString().c_str());
_tprintf(_T(" UrlEncode encode:%s\n"), Encode_UrlEncode::Encode(str).GetTString().c_str());
_tprintf(_T(" UrlEncode decode:%s\n"), Encode_UrlEncode::Decode(Encode_UrlEncode::Encode(str)).GetTString().c_str());
_tprintf(_T("\n"));

// 硬件信息
_tprintf(_T(" 硬件信息(需要管理员权限)\n -----------------------------\n"));
_tprintf(_T(" 硬盘序列号:%s\n"), Info_DiskSN::GetSN().GetTString().c_str());
_tprintf(_T(" MAC地址:%s\n"), Info_MacSN::GetSN().GetTString().c_str());
_tprintf(_T(" CPU序列号:%s\n"), Info_CpuSN::GetSN().GetTString().c_str());
_tprintf(_T(" 主板序列号:%s\n"), Info_BaseboardSN::GetSN().GetTString().c_str());
_tprintf(_T(" BIOS序列号:%s\n"), Info_BiosSN::GetSN().GetTString().c_str());
// hardware
_tprintf(_T(" Hardware Info(may need admin)\n -----------------------------\n"));
_tprintf(_T(" Disk SN:%s\n"), Info_DiskSN::GetSN().GetTString().c_str());
_tprintf(_T(" MAC Address:%s\n"), Info_MacSN::GetSN().GetTString().c_str());
_tprintf(_T(" CPU SN:%s\n"), Info_CpuSN::GetSN().GetTString().c_str());
_tprintf(_T(" Baseboard SN:%s\n"), Info_BaseboardSN::GetSN().GetTString().c_str());
_tprintf(_T(" BIOS SN:%s\n"), Info_BiosSN::GetSN().GetTString().c_str());
_tprintf(_T("\n"));

_tprintf(_T(" bignum大数库:\n -----------------------------\n"));
_tprintf(_T(" bignum library:\n -----------------------------\n"));
bignum s = 2;
s ^= 200;
_tprintf(_T(" 2^200=%s\n"), s.GetStr().GetTString().c_str());
Expand All @@ -77,4 +76,3 @@ int main() {
getchar();
return 0;
}

4 changes: 2 additions & 2 deletions Demo/Demo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>
</AdditionalDependencies>
<AdditionalLibraryDirectories>
Expand All @@ -150,7 +150,7 @@
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions Demo/Demo.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

0 comments on commit 15459d2

Please sign in to comment.