Skip to content

Sanya056756/openssl-evp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenSSL-EVP Helper

CodeFactor

OpenSSL-EVP Helper is a C++ library that makes it easier to work with EVP in the OpenSSL library.

Installation

Use CMake and module FetchContent to install OpenSSL-EVP Helper.

include(FetchContent)

FetchContent_Declare(
    openssl-evp
    GIT_REPOSITORY https://github.com/Sanya056756/openssl-evp.git
    GIT_TAG master
)

FetchContent_MakeAvailable(openssl-evp)

...

target_link_libraries(target_name PRIVATE OpenSSL::EVP_Helper)

Usage

#include <iostream>

#include <hash/hash.h>

class MD5 : public Hash
{
    MD5() : Hash("md5") {}
};

int main()
{
    MD5 md5;

    if (!md5.init())
        throw std::runtime_error("Failed to init MD5");

    if (!md5.update("Hello World!")) // Input string
        throw std::runtime_error("Failed to update MD5");

    if (!md5.final())
        throw std::runtime_error("Failed to final MD5");

    std::cout << "Final hex string is " << md5.hex() << std::endl;
}

Contributing

I'm always open to discussing any suggestions for improving the project.