Category: C

C

c – Output coloured text to a Windows terminal

GetStdHandle function retrieves a handle to the specified standard device (standard input, standard output, or standard error). GetConsoleScreenBufferInfo function retrieves information about the specified console screen buffer. SetConsoleTextAttribute function sets the attributes of characters written to the console screen buffer by the WriteFile or WriteConsole function, or echoed by the ReadFile or ReadConsole function. This …

C, Programming

RSA 2048 and Base64 using CryptoAPI and C

RSA is one of the first practical public-key cryptosystems and is widely used for secure data transmission. In such a cryptosystem, the encryption key is public and differs from the decryption key which is kept secret. In RSA, this asymmetry is based on the practical difficulty of factoring the product of two large prime numbers, …

C, Programming

AES 256 and Base64 using CryptoAPI and C

The Advanced Encryption Standard (AES), also known as Rijndael (its original name), is a specification for the encryption of electronic data established by the U.S. National Institute of Standards and Technology (NIST) in 2001. AES is based on the Rijndael cipher developed by two Belgian cryptographers, Joan Daemen and Vincent Rijmen, who submitted a proposal …

C, Programming

RC4 and Base64 using CryptoAPI and C

In cryptography, RC4 (Rivest Cipher 4 also known as ARC4 or ARCFOUR meaning Alleged RC4, see below) is a stream cipher. While remarkable for its simplicity and speed in software, multiple vulnerabilities have been discovered in RC4, rendering it insecure. It is especially vulnerable when the beginning of the output keystream is not discarded, or …

C, Programming

Base64 with CryptoAPI and C

CryptBinaryToString The CryptBinaryToString function converts an array of bytes into a formatted string. – MSDN CryptStringToBinary The CryptStringToBinary function converts a formatted string into an array of bytes. – MSDN Base64 Encoding bool Base64EncodeA(char **dest, unsigned long *dlen, const unsigned char *src, unsigned long slen) { if (src == NULL) return false;   if (!CryptBinaryToStringA(src, …

C, Programming

Calculate SHA 512 hash using C and CryptoAPI

SHA-2 (Secure Hash Algorithm 2) is a set of cryptographic hash functions designed by the National Security Agency (NSA).[3] SHA stands for Secure Hash Algorithm. Cryptographic hash functions are mathematical operations run on digital data; by comparing the computed “hash” (the output from execution of the algorithm) to a known and expected hash value, a …

C, Programming

Edit PE file properties using C

Using MS Windows API you can edit PE file properties such as: * File version * Product version * File Description * Company name * Internal name * Copyright * Original filename * Product name GetFileVersionInfoSize Determines whether the operating system can retrieve version information for a specified file. If version information is available, GetFileVersionInfoSize …