Source

Magnum / source / libs / magnum_crypto / source / magnum / crypto / SHA1Digester.cpp

/* 
  Magnum 
  Copyright (C) 2002-2011 Kaya Kupferschmidt. All Rights Reserved.

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, under the terms in LICENSE.TXT.

  Kaya Kupferschmidt  (k.kupferschmidt@dimajix.de)
*/

#include "magnum/openssl/OpenSSL.h"
#include "magnum/crypto/SHA1Digester.h"


namespace magnum { namespace crypto {
using magnum::openssl::OpenSSL;


/*--------------------------------------------------------------------------*/
/**
 */
SHA1Digester::SHA1Digester()
: AbstractDigester("SHA1")
{
    OpenSSL::startup();
    SHA1_Init(&m_Context);
}


/*--------------------------------------------------------------------------*/
/**
 */
SHA1Digester::~SHA1Digester()
{
}


/*--------------------------------------------------------------------------*/
/**
 */
void SHA1Digester::resetImpl()
{
    SHA1_Init(&m_Context);
}


/*--------------------------------------------------------------------------*/
/**
 */
void SHA1Digester::updateImpl(const void* data, size_t len)
{
    SHA1_Update(&m_Context, data, len);
}


/*--------------------------------------------------------------------------*/
/**
 */
ByteArray SHA1Digester::digestImpl()
{
    unsigned char buffer[SHA_DIGEST_LENGTH];
    SHA1_Final(buffer, &m_Context);
    return ByteArray((char*)buffer, SHA_DIGEST_LENGTH);
}

} }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.