Code Monkey home page Code Monkey logo

hcrypt's People

Contributors

vladp72 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hcrypt's Issues

С++20 deprecated error

Compiler version: MSVC v143
C++ Language Standard: C++20
Problem: I get error C4996: 'std::is_pod_v<unsigned long>': was declared deprecated when I try to compile the project on this build. Problematic line 773, located in the hbcrypt.hpp file. Either add a check for the compiler version and replace it with std::is_pod<T>{} == (std::is_trivial<T>{} && std::is_standard_layout<T>{}), or delete this assert

How to use hcrypt::from_hex?

unsigned char const key[] = {
	0x1b, 0x20, 0x5a, 0x9e, 0x2b, 0xe3, 0xfe, 0x85, 0x9c, 0x37, 0xf1,
	0xaf, 0xfe, 0x81, 0x88, 0x92, 0x9c, 0x37, 0xf1, 0xaf, 0xfe, 0x81,
	0x88, 0x92, 0x9c, 0x37, 0xf1, 0xaf, 0xfe, 0x81, 0x88, 0x92,
};

try {
	bcrypt::algorithm_provider ap{ BCRYPT_AES_ALGORITHM };
	ap.set_chaining_mode(BCRYPT_CHAIN_MODE_CCM);

	bcrypt::key k{ ap.generate_symmetric_key(
				  reinterpret_cast<char const*>(key),
				  32) };

	std::string_view aad("Not so secret additionally authenticated data");

	UCHAR iv[12] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc };
	UCHAR tag[16] = { 0 };

	BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO aadInfo;
	BCRYPT_INIT_AUTH_MODE_INFO(aadInfo);
	aadInfo.pbNonce = iv;
	aadInfo.cbNonce = sizeof(iv);
	aadInfo.pbAuthData = reinterpret_cast<UCHAR*>(const_cast<char*>(&aad[0]));
	aadInfo.cbAuthData = static_cast<ULONG>(aad.size());
	aadInfo.cbAAD = static_cast<ULONG>(aad.size());
	aadInfo.pbTag = tag;
	aadInfo.cbTag = sizeof(tag);

	size_t bytes_written{ 0 };
	k.encrypt(nullptr, 0, &aadInfo, nullptr, 0, nullptr, 0, &bytes_written);
	auto t = hcrypt::to_hex(std::begin(tag), std::end(tag));


        /////////////////////////////////
	**auto ta=hcrypt::from_hex(???);**
        ...

Hi,
The parameters you use may seem a bit confusing to someone not versed in c++.
image

Is it possible to reproduce a more readable function for example:
    string encrypt(string plaintext, string key);
    string decrypt(string code, string key);
I think that would be much more accessible.

Thanks you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.