• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

HashMD5.cc

Go to the documentation of this file.
00001 /** @file
00002 
00003   @section license License
00004 
00005   Licensed to the Apache Software Foundation (ASF) under one
00006   or more contributor license agreements.  See the NOTICE file
00007   distributed with this work for additional information
00008   regarding copyright ownership.  The ASF licenses this file
00009   to you under the Apache License, Version 2.0 (the
00010   "License"); you may not use this file except in compliance
00011   with the License.  You may obtain a copy of the License at
00012 
00013       http://www.apache.org/licenses/LICENSE-2.0
00014 
00015   Unless required by applicable law or agreed to in writing, software
00016   distributed under the License is distributed on an "AS IS" BASIS,
00017   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018   See the License for the specific language governing permissions and
00019   limitations under the License.
00020  */
00021 
00022 #include "HashMD5.h"
00023 
00024 ATSHashMD5::ATSHashMD5(void) {
00025     EVP_DigestInit(&ctx, EVP_md5());
00026     md_len = 0;
00027     finalized = false;
00028 }
00029 
00030 void
00031 ATSHashMD5::update(const void *data, size_t len) {
00032     if (!finalized) {
00033         EVP_DigestUpdate(&ctx, data, len);
00034     }
00035 }
00036 
00037 void
00038 ATSHashMD5::final(void) {
00039     if (!finalized) {
00040         EVP_DigestFinal_ex(&ctx, md_value, &md_len);
00041         finalized = true;
00042     }
00043 }
00044 
00045 const void *
00046 ATSHashMD5::get(void) const {
00047     if (finalized) {
00048         return (void *) md_value;
00049     } else {
00050         return NULL;
00051     }
00052 }
00053 
00054 size_t
00055 ATSHashMD5::size(void) const {
00056     return EVP_MD_CTX_size(&ctx);
00057 }
00058 
00059 void
00060 ATSHashMD5::clear(void) {
00061     EVP_MD_CTX_cleanup(&ctx);
00062     EVP_DigestInit(&ctx, EVP_md5());
00063     md_len = 0;
00064     finalized = false;
00065 }
00066 
00067 ATSHashMD5::~ATSHashMD5() {
00068     EVP_MD_CTX_cleanup(&ctx);
00069 }

Generated by  doxygen 1.7.1