Skip to content

Commit

Permalink
Added hashToHex function
Browse files Browse the repository at this point in the history
  • Loading branch information
GamePad64 committed Mar 3, 2013
1 parent 54c4a9e commit 067b5da
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
34 changes: 17 additions & 17 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="src/daemon/extensions|test/daemon|src/daemon/net/asio|src/daemon/connections|src/common/databases|test" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry excluding="test" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
Expand Down Expand Up @@ -211,35 +211,35 @@
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.cpp.compiler.base.258280919;cdt.managedbuild.tool.gnu.cpp.compiler.input.1125444161">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.479341538;cdt.managedbuild.config.gnu.cross.exe.release.479341538.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.871354690;cdt.managedbuild.tool.gnu.cpp.compiler.input.1121145535">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.c.compiler.base.1227577773;cdt.managedbuild.tool.gnu.c.compiler.input.1314765529">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.c.compiler.base.533858670;cdt.managedbuild.tool.gnu.c.compiler.input.1590373015">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.890719355;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.890719355.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1402720721;cdt.managedbuild.tool.gnu.cpp.compiler.input.267427808">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.479341538;cdt.managedbuild.config.gnu.cross.exe.release.479341538.;cdt.managedbuild.tool.gnu.cross.c.compiler.355857388;cdt.managedbuild.tool.gnu.c.compiler.input.2068872730">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.cross.c.compiler.1540105406;cdt.managedbuild.tool.gnu.c.compiler.input.246454339">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.cpp.compiler.base.72286408;cdt.managedbuild.tool.gnu.cpp.compiler.input.402910217">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.890719355;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.890719355.;cdt.managedbuild.tool.gnu.c.compiler.base.1718763147;cdt.managedbuild.tool.gnu.c.compiler.input.1922864039">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.947866191;cdt.managedbuild.tool.gnu.cpp.compiler.input.1617370535">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.890719355;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.890719355.;cdt.managedbuild.tool.gnu.c.compiler.base.1718763147;cdt.managedbuild.tool.gnu.c.compiler.input.1922864039">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.cpp.compiler.base.72286408;cdt.managedbuild.tool.gnu.cpp.compiler.input.402910217">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.890719355;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.890719355.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1402720721;cdt.managedbuild.tool.gnu.cpp.compiler.input.267427808">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.cross.c.compiler.1540105406;cdt.managedbuild.tool.gnu.c.compiler.input.246454339">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.479341538;cdt.managedbuild.config.gnu.cross.exe.release.479341538.;cdt.managedbuild.tool.gnu.cross.c.compiler.355857388;cdt.managedbuild.tool.gnu.c.compiler.input.2068872730">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.c.compiler.base.533858670;cdt.managedbuild.tool.gnu.c.compiler.input.1590373015">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.c.compiler.base.1227577773;cdt.managedbuild.tool.gnu.c.compiler.input.1314765529">
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1766732349;cdt.managedbuild.config.gnu.cross.exe.debug.1766732349.;cdt.managedbuild.tool.gnu.cpp.compiler.base.258280919;cdt.managedbuild.tool.gnu.cpp.compiler.input.1125444161">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.479341538;cdt.managedbuild.config.gnu.cross.exe.release.479341538.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.871354690;cdt.managedbuild.tool.gnu.cpp.compiler.input.1121145535">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
</scannerConfigBuildInfo>
</storageModule>
</cproject>
14 changes: 14 additions & 0 deletions src/common/crypto/CryptoFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/

#include "CryptoTypes.h"
#include <sstream>
#include <string>
#include <iomanip>

namespace p2pnet {
namespace crypto {
Expand All @@ -38,6 +41,17 @@ unsigned short hashDistance(hash_t hash1, hash_t hash2){
return distance;
}

std::string hashToHex(hash_t hash){
std::ostringstream hash_ss;

hash_ss << std::hex << std::uppercase << std::setfill('0');
for( int twobytes : hash ) {
hash_ss << std::setw(2) << twobytes;
}

return hash_ss.str();
}


} /* namespace crypto */
} /* namespace p2pnet */
2 changes: 2 additions & 0 deletions src/common/crypto/CryptoTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ typedef std::vector<Botan::byte, Botan::secure_allocator<Botan::byte> > hash_t;

//! Hamming distance of two hash_t
unsigned short hashDistance(hash_t hash1, hash_t hash2);
//! Returns Hex value of hash
std::string hashToHex(hash_t hash);
} /* namespace crypto */
} /* namespace p2pnet */

Expand Down

0 comments on commit 067b5da

Please sign in to comment.