bug fixes and tests for aes
This commit is contained in:
parent
d7eb7efb65
commit
311a9652d4
3 changed files with 35 additions and 1 deletions
|
|
@ -134,4 +134,6 @@ set( BOOST_LIBRARIES ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FIL
|
|||
|
||||
#add_executable( test_compress tests/compress.cpp )
|
||||
#target_link_libraries( test_compress fc ${BOOST_LIBRARIES} )
|
||||
#add_executable( test_aes tests/aes_test.cpp )
|
||||
#target_link_libraries( test_aes fc ${BOOST_LIBRARIES} )
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <fc/sha512.hpp>
|
||||
#include <fc/crypto/sha512.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace fc {
|
||||
|
||||
|
|
|
|||
31
tests/aes_test.cpp
Normal file
31
tests/aes_test.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include <iostream>
|
||||
#include <fc/crypto/aes.hpp>
|
||||
#include <fc/exception/exception.hpp>
|
||||
|
||||
int main( int argc, char** )
|
||||
{
|
||||
std::string line;
|
||||
std::getline( std::cin, line );
|
||||
auto key = fc::sha512::hash( "hello", 5 );
|
||||
while( std::cin && line != "q" )
|
||||
{
|
||||
try {
|
||||
std::vector<char> data( line.c_str(),line.c_str()+line.size()+1 );
|
||||
std::vector<char> crypt = fc::aes_encrypt( key, data );
|
||||
std::vector<char> dcrypt = fc::aes_decrypt( key, crypt );
|
||||
|
||||
std::cout<<"line.size: '"<<line.size()<<"'\n";
|
||||
std::cout<<"data.size: '"<<data.size()<<"'\n";
|
||||
std::cout<<"crypt.size: '"<<crypt.size()<<"'\n";
|
||||
std::cout<<"dcrypt.size: '"<<dcrypt.size()<<"'\n";
|
||||
std::cout<<"line: '"<<line<<"'\n";
|
||||
std::cout<<"dcrypt: '"<<dcrypt.data()<<"'\n";
|
||||
}
|
||||
catch ( fc::exception& e )
|
||||
{
|
||||
std::cout<<e.to_detail_string()<<"\n";
|
||||
}
|
||||
std::getline( std::cin, line );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in a new issue