/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #include "hash/nsha1.h" #include "hash/sha1.h" #include "container/narray.h" #include "nstring/nstring.h" using namespace GS; //------------------------------------------------------------------------------ void SHA1::ComputeHash(const String &source, Array &hash) { if (hash.Allocate(20)) sha1::calc(source.c_str(), source.Len(), hash.c_ptr()); } String SHA1::ComputeHexa(const String &source) { Array hash; ComputeHash(source, hash); char hex[41]; sha1::toHexString(hash.c_ptr(), hex); return String(hex); } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void SHA1::ComputeHash(const Array &data, Array &hash) { if (hash.Allocate(20)) sha1::calc(data.c_ptr(), data.GetSize(), hash.c_ptr()); } String SHA1::ComputeHexa(const Array &data) { Array hash; ComputeHash(data, hash); char hex[41]; sha1::toHexString(hash.c_ptr(), hex); return String(hex); } //------------------------------------------------------------------------------