Hot Door CORE  0.7.1
Adobe® Illustrator® Plug-in Library
Classes | Typedefs | Functions
hdicoreCrypt.h File Reference

Header file for performing hashing, encoding, or encrypting data. More...

Classes

class  hdi::core::crypt::aes::Key
 Wraps around an AES key's raw data for some added conveniences. More...
 
class  hdi::core::crypt::aes::InitVector
 Wraps around an AES initialization vector's raw data for some added conveniences. More...
 
class  hdi::core::crypt::rsa::PublicKey
 Wraps around a public RSA key's raw data for some added conveniences. More...
 
class  hdi::core::crypt::rsa::PrivateKey
 Wraps around a private RSA key's raw data for some added conveniences. More...
 

Typedefs

typedef std::vector< byte > hdi::core::crypt::aes::ByteVector
 
typedef std::auto_ptr< Key > hdi::core::crypt::aes::KeyAP
 
typedef std::auto_ptr< InitVector > hdi::core::crypt::aes::InitVectorAP
 
typedef std::auto_ptr< PublicKey > hdi::core::crypt::rsa::PublicKeyAP
 
typedef std::auto_ptr< PrivateKey > hdi::core::crypt::rsa::PrivateKeyAP
 

Functions

std::string hdi::core::crypt::rot13 (const std::string &str_)
 Performs a rot-13 cipher (Caeser's cipher) on a string. More...
 
std::string hdi::core::crypt::md5 (const std::string &str_)
 Generates an MD5 hash of a given source string. More...
 
std::string hdi::core::crypt::sha1 (const std::string &str_)
 Generates an SHA1 hash of a given source string. More...
 
std::string hdi::core::crypt::sha2_256 (const std::string &str_)
 Generates an SHA2-256 hash of a given source string. More...
 
std::string hdi::core::crypt::sha2_512 (const std::string &str_)
 Generates an SHA2-512 hash of a given source string. More...
 
std::string hdi::core::crypt::base64Encode (const std::string &plain_)
 Base-64 encodes any data stuffed into a string. More...
 
std::string hdi::core::crypt::base64Decode (const std::string &cipher_)
 Decodes any data previously base-64 encoded. More...
 
bool hdi::core::crypt::aes::encrypt (const Key &key_, const InitVector &iv_, const std::string &data_, std::string &b64Cipher__)
 Encrypts a string (or raw bytes stuffed into a string) with an AES key. More...
 
bool hdi::core::crypt::aes::decrypt (const Key &key_, const InitVector &iv_, const std::string &b64Cipher_, std::string &data__)
 Decrypts a base-64 encoded string of cipher text (previously encrypted with the encrypt() function or equivalent) More...
 
plugin::AESKey * hdi::core::crypt::aes::__accessImpl (const Key &)
 
plugin::AESInitializationVector * hdi::core::crypt::aes::__accessImpl (const InitVector &)
 
bool hdi::core::crypt::rsa::generateKeyPair (const int32_t size_, PrivateKey &privKey__, PublicKey &pubKey__)
 Generates a new RSA key pair of a given size/length. More...
 
bool hdi::core::crypt::rsa::encryptWithPublicKey (const PublicKey &key_, const std::string &data_, std::string &b64Cipher__)
 Encrypts a string (or raw bytes stuffed into a string) with a public RSA key. More...
 
bool hdi::core::crypt::rsa::decryptWithPrivateKey (const PrivateKey &key_, const std::string &b64Cipher_, std::string &data__)
 Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPublicKey() function or equivalent) More...
 
bool hdi::core::crypt::rsa::encryptWithPrivateKey (const PrivateKey &key_, const std::string &data_, std::string &b64Cipher__)
 Encrypts a string (or raw bytes stuffed into a string) with a private RSA key. More...
 
bool hdi::core::crypt::rsa::decryptWithPublicKey (const PublicKey &key_, const std::string &b64Cipher_, std::string &data__)
 Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPrivateKey() function or equivalent) More...
 

Detailed Description

Header file for performing hashing, encoding, or encrypting data.

Function Documentation

◆ base64Decode()

std::string hdi::core::crypt::base64Decode ( const std::string &  cipher_)

Decodes any data previously base-64 encoded.

Author
GW
Date
08/2013
Parameters
cipher_Base-64 encoded text to decode
Returns
The value of the cipher_ argument, but base-64 decoded

◆ base64Encode()

std::string hdi::core::crypt::base64Encode ( const std::string &  plain_)

Base-64 encodes any data stuffed into a string.

Author
GW
Date
08/2013
Parameters
plain_Plain text (or binary data stuffed in a string) to base-64 encode
Returns
The value of the plain_ argument, but base-64 encoded

◆ decrypt()

bool hdi::core::crypt::aes::decrypt ( const Key key_,
const InitVector iv_,
const std::string &  b64Cipher_,
std::string &  data__ 
)

Decrypts a base-64 encoded string of cipher text (previously encrypted with the encrypt() function or equivalent)

Author
GW
Date
10/2013
Parameters
key_AES key to use for decryption
iv_Initialization vector to use for this decryption call
b64Cipher_Base-64 encoded cipher text to attempt to decrypt
data__Return-by-reference for the decrypted plain text (or raw bytes stuffed into a string)
Returns
true if the data could be decrypted, false otherwise

◆ decryptWithPrivateKey()

bool hdi::core::crypt::rsa::decryptWithPrivateKey ( const PrivateKey key_,
const std::string &  b64Cipher_,
std::string &  data__ 
)

Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPublicKey() function or equivalent)

Author
GW
Date
10/2013
Parameters
key_Private RSA key to use for decryption
b64Cipher_Base-64 encoded cipher text to attempt to decrypt
data__Return-by-reference for the decrypted plain text (or raw bytes stuffed into a string)
Returns
true if the data could be decrypted, false otherwise

◆ decryptWithPublicKey()

bool hdi::core::crypt::rsa::decryptWithPublicKey ( const PublicKey key_,
const std::string &  b64Cipher_,
std::string &  data__ 
)

Decrypts a base-64 encoded string of cipher text (previously encrypted with the encryptWithPrivateKey() function or equivalent)

Author
GW
Date
10/2013
Parameters
key_Public RSA key to use for decryption
b64Cipher_Base-64 encoded cipher text to attempt to decrypt
data__Return-by-reference for the decrypted plain text (or raw bytes stuffed into a string)
Returns
true if the data could be decrypted, false otherwise

◆ encrypt()

bool hdi::core::crypt::aes::encrypt ( const Key key_,
const InitVector iv_,
const std::string &  data_,
std::string &  b64Cipher__ 
)

Encrypts a string (or raw bytes stuffed into a string) with an AES key.

Author
GW
Date
10/2013
Parameters
key_AES key to use for encryption
iv_Initialization vector to use for this encryption call
data_Plain data to be encrypted (in the form of a string or binary data inside of a string object)
b64Cipher__Return-by-reference for the base-64 encoded cipher text
Returns
true if the data could be encrypted, false otherwise
Note
To decrypt the cipher, use the decrypt() function (or equivalent - this lib is built on OpenSSL and the AES standard, so any base-64 decoder and function that understands AES decryption can decrypt the cipher with the correct key and initialization vector).

◆ encryptWithPrivateKey()

bool hdi::core::crypt::rsa::encryptWithPrivateKey ( const PrivateKey key_,
const std::string &  data_,
std::string &  b64Cipher__ 
)

Encrypts a string (or raw bytes stuffed into a string) with a private RSA key.

Author
GW
Date
10/2013
Parameters
key_Private RSA key to use for encryption
data_Plain data to be encrypted (in the form of a string or binary data put inside of a string object)
b64Cipher__Return-by-reference for the base-64 encoded cipher text
Returns
true if the data could be encrypted, false otherwise
Note
To decrypt the cipher, use the decryptWithPublicKey() function (or equivalent - this lib is built on OpenSSL and the RSA standard, so any base-64 decoder and function that understands RSA private key decryption can decrypt the cipher with the correct key).
Typically, sensitive data is not encrypted with a private key because anyone with the public key can decrypt it. However, "signing" (encrypting) some token data with a private key is a common practice to prove to a holder of the public key that the true owner of the private key e.g. received a message and is responding to it (as only the holder of the private key could do this).

◆ encryptWithPublicKey()

bool hdi::core::crypt::rsa::encryptWithPublicKey ( const PublicKey key_,
const std::string &  data_,
std::string &  b64Cipher__ 
)

Encrypts a string (or raw bytes stuffed into a string) with a public RSA key.

Author
GW
Date
10/2013
Parameters
key_Public RSA key to use for encryption
data_Plain data to be encrypted (in the form of a string or binary data put inside of a string object)
b64Cipher__Return-by-reference for the base-64 encoded cipher text
Returns
true if the data could be encrypted, false otherwise
Note
To decrypt the cipher, use the decryptWithPrivateKey() function (or equivalent - this lib is built on OpenSSL and the RSA standard, so any base-64 decoder and function that understands RSA private key decryption can decrypt the cipher with the correct key).

◆ generateKeyPair()

bool hdi::core::crypt::rsa::generateKeyPair ( const int32_t  size_,
PrivateKey privKey__,
PublicKey pubKey__ 
)

Generates a new RSA key pair of a given size/length.

Author
GW
Date
10/2013
Parameters
size_Size/length of the key in bits (must be n*1024; not recommended for n>16)
privKey__Return-by-reference for the new private key
pubKey__Return-by-reference for the new public key
Returns
true if the key pair could be generated, false otherwise
Note
A minimum key size of 2048 bits is recommended.

◆ md5()

std::string hdi::core::crypt::md5 ( const std::string &  str_)

Generates an MD5 hash of a given source string.

Author
GW
Date
05/2017
Parameters
str_String to hash with the MD5 algorithm (binary data inside of a string is also acceptable)
Returns
A string representing the hexadecimal data of the MD5 hash value

◆ rot13()

std::string hdi::core::crypt::rot13 ( const std::string &  str_)

Performs a rot-13 cipher (Caeser's cipher) on a string.

Author
GW
Date
08/2013
Parameters
str_String on which the rotation will be performed
Returns
Value of str_ argument, but with all alphabetic characters rotated by 13 positions
Note
Only the ASCII portion of the string will be rotated.

◆ sha1()

std::string hdi::core::crypt::sha1 ( const std::string &  str_)

Generates an SHA1 hash of a given source string.

Author
GW
Date
08/2013
Parameters
str_String to hash with the SHA1 algorithm (binary data inside of a string is also acceptable)
Returns
A string representing the hexadecimal data of the SHA1 hash value

◆ sha2_256()

std::string hdi::core::crypt::sha2_256 ( const std::string &  str_)

Generates an SHA2-256 hash of a given source string.

Author
GW
Date
05/2017
Parameters
str_String to hash with the SHA2-256 algorithm (binary data inside of a string is also acceptable)
Returns
A string representing the hexadecimal data of the SHA2-256 hash value

◆ sha2_512()

std::string hdi::core::crypt::sha2_512 ( const std::string &  str_)

Generates an SHA2-512 hash of a given source string.

Author
GW
Date
05/2017
Parameters
str_String to hash with the SHA2-512 algorithm (binary data inside of a string is also acceptable)
Returns
A string representing the hexadecimal data of the SHA2-512 hash value