Arrange code
This commit is contained in:
parent
5783bf5e10
commit
ecda75a273
2 changed files with 23 additions and 18 deletions
|
@ -26,7 +26,7 @@ AESCrypt::~AESCrypt(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Encrypt string
|
//Encrypt string with string key
|
||||||
std::string AESCrypt::encrypt(std::string key, std::string data){
|
std::string AESCrypt::encrypt(std::string key, std::string data){
|
||||||
|
|
||||||
//Generate SHA-256
|
//Generate SHA-256
|
||||||
|
@ -36,14 +36,13 @@ std::string AESCrypt::encrypt(std::string key, std::string data){
|
||||||
return encryptRoutine(data, digest, sizeof(digest));
|
return encryptRoutine(data, digest, sizeof(digest));
|
||||||
|
|
||||||
}
|
}
|
||||||
//Encrypt string
|
|
||||||
|
//Encrypt string with byte* key
|
||||||
std::string AESCrypt::encrypt(byte* key, std::string data){
|
std::string AESCrypt::encrypt(byte* key, std::string data){
|
||||||
|
|
||||||
return encryptRoutine(data, key, 32);
|
return encryptRoutine(data, key, 32);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//The encryptRoutine
|
||||||
std::string AESCrypt::encryptRoutine(std::string data, byte* digest, int size){
|
std::string AESCrypt::encryptRoutine(std::string data, byte* digest, int size){
|
||||||
//Contain data encrypted
|
//Contain data encrypted
|
||||||
std::string cipher;
|
std::string cipher;
|
||||||
|
@ -79,14 +78,6 @@ std::string AESCrypt::encryptRoutine(std::string data, byte* digest, int size){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Decrypt string
|
//Decrypt string
|
||||||
std::string AESCrypt::decrypt(std::string key, std::string data){
|
std::string AESCrypt::decrypt(std::string key, std::string data){
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,21 @@ class AESCrypt : public AbstractSKA {
|
||||||
~AESCrypt();
|
~AESCrypt();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Run encryptRoutine.
|
||||||
|
*
|
||||||
|
* @param key : key used to encrypt data
|
||||||
|
* @param data : contain data to encrypt.
|
||||||
|
*
|
||||||
|
* @return string : correspond to crypted data
|
||||||
|
*
|
||||||
|
* Run encryptRoutine with byte* key or string key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::string encrypt(std::string key, std::string data);
|
||||||
|
std::string encrypt(byte* key, std::string data);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Encrypt data with AES algorithm.
|
* @brief Encrypt data with AES algorithm.
|
||||||
*
|
*
|
||||||
|
@ -48,11 +63,13 @@ class AESCrypt : public AbstractSKA {
|
||||||
*
|
*
|
||||||
* @return string : correspond to crypted data
|
* @return string : correspond to crypted data
|
||||||
*
|
*
|
||||||
* Encrypt data, and return them in a string.
|
* Encrypt data, and return them into a string.
|
||||||
* Padding are blank space.
|
* Padding are blank space.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual std::string encrypt(std::string key, std::string data);
|
std::string encryptRoutine(std::string data, byte* digest, int size);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Decrypt data from AES algorithm.
|
* @brief Decrypt data from AES algorithm.
|
||||||
|
@ -67,9 +84,6 @@ class AESCrypt : public AbstractSKA {
|
||||||
*/
|
*/
|
||||||
virtual std::string decrypt(std::string key, std::string data);
|
virtual std::string decrypt(std::string key, std::string data);
|
||||||
|
|
||||||
std::string encrypt(byte* key, std::string data);
|
|
||||||
|
|
||||||
std::string encryptRoutine(std::string data, byte* digest, int size);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue