Re: [cryptopp-users] Re: SonarLint complaining about "Use a stronger padding scheme"

2024-04-24 Thread Manish sharma
Crypto Betting  

On Wed, Apr 24, 2024 at 6:08 PM Frank Sapone 
wrote:

> Has anyone figured out how to use PSS and SHA256 *WITH *CryptoPP-PEM?  I
> also tried reporting this to the issuer tracker at
> https://github.com/noloader/cryptopp-pem and nobody has replied.  I can't
> imagine I'm the only person using this library in order to achieve this
> with X509 Certs.
>
> Thanks,
> Frank
>
> On Wednesday, April 17, 2024 at 11:43:54 AM UTC-4 HELA YAICH wrote:
>
>> Hello,
>> (I'm new user of ns3 and crypto)
>> I have link errors with Crypto++. These errors indicate that the compiler
>> cannot find certain functions or classes defined in Crypto++. This can
>> happen if Crypto++ is not correctly linked to my project. However, I tried
>> to modify my project's CMakeLists.txt file as follows:
>> set(target_prefix scratch_)
>>
>> function(create_scratch source_files)
>>   # Return early if no sources in the subdirectory
>>   list(LENGTH source_files number_sources)
>>   if(number_sources EQUAL 0)
>> return()
>>   endif()
>>
>>   # If the scratch has more than a source file, we need to find the
>> source with
>>   # the main function
>>   set(scratch_src)
>>   foreach(source_file ${source_files})
>> file(READ ${source_file} source_file_contents)
>> string(REGEX MATCHALL "main[(| (]" main_position
>> "${source_file_contents}")
>> if(CMAKE_MATCH_0)
>>   set(scratch_src ${source_file})
>> endif()
>>   endforeach()
>>
>>   if(NOT scratch_src)
>> return()
>>   endif()
>>
>>   # Get parent directory name
>>   get_filename_component(scratch_dirname ${scratch_src} DIRECTORY)
>>   string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" scratch_dirname
>>  "${scratch_dirname}"
>>   )
>>   string(REPLACE "/" "_" scratch_dirname "${scratch_dirname}")
>>
>>   # Get source name
>>   get_filename_component(scratch_name ${scratch_src} NAME_WE)
>>
>>   set(target_prefix scratch_)
>>   if(scratch_dirname)
>> # Join the names together if dirname is not the scratch folder
>> set(target_prefix scratch${scratch_dirname}_)
>>   endif()
>>
>>   # Get source absolute path and transform into relative path
>>   get_filename_component(scratch_src ${scratch_src} ABSOLUTE)
>>   get_filename_component(scratch_absolute_directory ${scratch_src}
>> DIRECTORY)
>>   string(REPLACE "${PROJECT_SOURCE_DIR}" "${CMAKE_OUTPUT_DIRECTORY}"
>>  scratch_directory ${scratch_absolute_directory}
>>   )
>>   add_executable(${target_prefix}${scratch_name} "${source_files}")
>>   if(${NS3_STATIC})
>> target_link_libraries(
>>   ${target_prefix}${scratch_name} ${LIB_AS_NEEDED_PRE_STATIC}
>>   ${lib-ns3-static}
>> )
>>   else()
>> target_link_libraries(
>>   ${target_prefix}${scratch_name} "${ns3-libs}" "${ns3-contrib-libs}"
>>   "${ns3-external-libs}"
>> )
>>   endif()
>>   set_runtime_outputdirectory(
>> ${scratch_name} ${scratch_directory}/ ${target_prefix}
>>   )
>> endfunction()
>>
>> # Scan *.cc files in ns-3-dev/scratch and build a target for each
>> file(GLOB single_source_file_scratches CONFIGURE_DEPENDS
>> ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
>> foreach(scratch_src ${single_source_file_scratches})
>>   create_scratch(${scratch_src})
>> endforeach()
>>
>> # Scan *.cc files in ns-3-dev/scratch subdirectories and build a target
>> for each
>> # subdirectory
>> file(
>>   GLOB_RECURSE scratch_subdirectories
>>   CONFIGURE_DEPENDS
>>   LIST_DIRECTORIES true
>>   ${CMAKE_CURRENT_SOURCE_DIR}/**
>> )
>> # Filter out files
>> foreach(entry ${scratch_subdirectories})
>>   if(NOT (IS_DIRECTORY ${entry}))
>> list(REMOVE_ITEM scratch_subdirectories ${entry})
>>   endif()
>> endforeach()
>>
>> foreach(subdir ${scratch_subdirectories})
>>   if(EXISTS ${subdir}/CMakeLists.txt)
>> # If the subdirectory contains a CMakeLists.txt file
>> # we let the CMake file manage the source files
>> #
>> # Use this if you want to link to external libraries
>> # without creating a module
>> add_subdirectory(${subdir})
>>   else()
>> # Otherwise we pick all the files in the subdirectory
>> # and create a scratch for them automatically
>> file(GLOB scratch_sources CONFIGURE_DEPENDS ${subdir}/*.cc)
>> create_scratch("${scratch_sources}")
>>   endif()
>> endforeach()
>> find_external_library(DEPENDENCY_NAME cryptopp
>>   HEADER_NAME aes.h
>>   LIBRARY_NAME cryptopp
>>   SEARCH_PATHS /usr/include/cryptopp)
>>
>>
>> if(${CRYPTOPP_FOUND}) # Notice that the contents of DEPENDENCY_NAME
>> became a prefix for the _FOUND variable
>> find_package(cryptopp REQUIRED)
>> include_directories(${CRYPTOPP_INCLUDE_DIRS})
>> link_libraries(${CRYPTOPP_LIBRARIES})
>> endif()
>> add_executable(${target_prefix}${scratch_name} "fanetex.cc")
>> target_link_libraries(${target_prefix}${scratch_name} PRIVATE cryptopp)
>>
>> can you help me to solve this problem

Re: [cryptopp-users] Re: How to decrypt a file in memory?

2022-09-22 Thread Manish sharma
Hi,

How to Launch Smart Contract-Based Cryptocurrency MLM Software?


On Thu, Sep 22, 2022 at 2:31 PM Anton Schmidt 
wrote:

> Just load file data into memory buffer (std::vector) and
> use filter pipeline with VectorSource and VectorSink.
> https://cryptopp.com/docs/ref/class_vector_source.html
> https://cryptopp.com/docs/ref/class_vector_sink.html
>
> четверг, 22 сентября 2022 г. в 00:59:54 UTC+7, kakaa...@gmail.com:
>
>> I'm encrypting a file this way:
>>
>>
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>> #include 
>>
>>
>> void FileEncrypt(byte key[], byte iv[]
>>, const std::string& file, const std::string& dest)
>> {
>> CTR_Mode< AES >::Encryption cipher;
>> cipher.SetKeyWithIV(key, strlen((char*)key), iv,
>> strlen((char*)iv));
>>
>> std::ifstream in{file, std::ios::binary};
>> std::ofstream out{dest, std::ios::binary};
>>
>> CryptoPP::FileSource{in, true,
>> new CryptoPP::StreamTransformationFilter{
>> cipher, new CryptoPP::FileSink{out}}};
>> }
>>
>> INT main(INT argc, PCHAR* argv)
>> {
>> std::string file = "...";
>> std::string dest = "...";
>>
>> unsigned char* key[] = "p3s6v9y$B&E)H@Mc";
>> unsigned char* iv[] = "VkXp2s5v8y/B?E(H";
>>
>> FileEncrypt(key, iv, file, dest);
>> FileDecrypt(key, iv, file, dest);
>> }
>>
>>
>> Then when needed i'm downloading the encrypted file from my repo.
>>
>> I've been able to decrypt it with:
>>
>> ```c++
>> void FileDecrypt(byte key[], byte iv[]
>>, const std::string& file, const std::string& dest)
>> {
>>  CTR_Mode< AES >::Decryption cipher;
>>  cipher.SetKeyWithIV(key, strlen((char*)key), iv,
>> strlen((char*)iv));
>>
>>  std::ifstream in{file, std::ios::binary};
>>  std::ofstream out{dest, std::ios::binary};
>>
>>  CryptoPP::FileSource{in, true,
>>   new CryptoPP::StreamTransformationFilter{
>>   cipher, new CryptoPP::FileSink{out}}};
>> }
>> ```
>> But this way the decrypted file is saved to disk, how could i decrypt it
>> on memory without saving to disk?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Crypto++ Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cryptopp-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cryptopp-users/15333873-9cf5-428e-a22b-82b9f9b5b5e8n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/CABUB1NT5UToHVdoQoUDWPjaRxth2K4YXMyLAmBuyw88kJ_F7Gw%40mail.gmail.com.


Re: [cryptopp-users] How to calculate hash of a string vector?

2022-04-04 Thread Manish sharma
You can make your own crypto exchange App & Software . Read More to know 
how? 
Cryptocurrency Exchange Development Cost & Features 



On Thursday, February 3, 2022 at 7:55:09 AM UTC+5:30 Jeffrey Walton wrote:

> On Wed, Feb 2, 2022 at 12:19 PM Devharsh Trivedi
>  wrote:
> >
> > I am trying to calculate SHA256 digest for entire string vector like 
> this:
> >
> > byte digest[SHA256::DIGESTSIZE];
> > SHA256().CalculateDigest(digest, (const byte*)stringVector.data(), 
> stringVector.size());
> >
> > What is the correct way to calculate hash of entire vector?
> https://www.cryptopp.com/wiki/SHA2
>
> Jeff
>

-- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/4a406c1b-d160-474d-9ec1-567c3987b430n%40googlegroups.com.