?? cryptodata.cpp
字號:
#include "cryptoData.h"CryptoData::CryptoData(){}CryptoData::~CryptoData(){}string CryptoData::encryptoData(string data){ X509_ALGOR *alg=X509_ALGOR_new(); if (alg->algorithm != NULL) ASN1_OBJECT_free(alg->algorithm); alg->algorithm=OBJ_nid2obj(NID_rsaEncryption); if ((alg->parameter=ASN1_TYPE_new()) == NULL) cout << "error"<<endl; alg->parameter->type=V_ASN1_NULL; PKCS7* p7 = PKCS7_new(); assert(p7!=NULL); int err = PKCS7_set_type(p7, NID_pkcs7_enveloped); const EVP_CIPHER *cipher=NULL; if (!cipher) { cipher = EVP_des_ede3_cbc(); } err = PKCS7_set_cipher(p7, cipher);// PKCS7_RECIP_INFO *info = PKCS7_add_recipient(); X509_ALGOR_free(alg);}string CryptoData::decryptoData(string data){}
string CryptoData::readCAconfig(string keyword, string objectName)
{
string result = "";
FILE *fd = fopen(CA_CONFIG_PATH, "r");
assert(fd != NULL);
if (fd == NULL) {
result.append("");
}
else {
char *line = (char*)calloc(1, 1*K);
string config="";
while (!feof(fd)) {
memset(line, 0, 1*K);
fgets(line, 1*K, fd);
config.append(line);
}
fclose(fd);
NggObject *object = NggObject::fromXML(config);
assert( object!=NULL );
for (int i=0; i<object->m_Contains.size(); i++) {
if (object->m_Contains[i]->m_Name==keyword) {
if (keyword == "Root" || keyword == "Operator" || keyword == "Administrator"|| keyword=="SerialNumber") {
result.append(object->m_Contains[i]->m_Value);
}
else {
NggObject* nggobject = object->m_Contains[i];
assert( nggobject!=NULL );
for (int ii=0; ii<nggobject->m_Contains.size(); ii++) {
if (nggobject->m_Contains[ii]->m_Name==objectName) {
result.append(nggobject->m_Contains[ii]->m_Value);
break;
}
}
if (nggobject) nggobject=NULL;
}
break;
}
}
if (object) delete object, object=NULL ;
if (line) free(line), line=NULL;
}
return result;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -