開源專案之NeoCrypt 加密解密

2021-06-09 07:02:04 字數 2075 閱讀 8201

乙個檔案加密解密軟體的源**,可以設定很多著名的加密演算法進行加密解密。它集強力、安全的演算法和簡單、易用的介面於一身。它的檔案管理介面可以輕易地**和更改整個系 統的加密設定,也可以加/解密選定的檔案,安全地刪除檔案。它支援多使用者使用。如圖:

專案需要用到第三方庫cryptlib,該庫已經放到原始碼包中。

本程式有乙個動態鏈結庫neocryptsx與乙個主程式neocrypt組成,neocryptsx動態庫操作簡單,只負責傳送呼叫訊息,neocrypt主程式中封裝了decryptor類負責解碼、encryptor類負責編碼,file類負責檔案操作、cprogupdater類負責進度等。

解碼部分:

void decryptor::decrypt(const std::string& name,std::list& pwds)}}

while (cryptsetattribute(env,crypt_envinfo_password,crypt_cursor_next) == crypt_ok);

if (accept)

break;}}

if (it == end)

throw std::runtime_error("none of the passwords are valid for file " + name + " ! please try another password.");

}else if (status != 0)

bytesleft -= cbytes;

bytesdone += cbytes;

cryptpopdata(env,buf,buffer_size,&cbytes);

file.write(buf,cbytes);

} if (mlistener)

mlistener->increment(n);

} // flush remaining data

cryptflushdata(env);

cryptpopdata(env,buf,buffer_size,&n);

file.write(buf,n);

// destroy envelope

cryptdestroyenvelope(env);

// close file

file.close();

mlistener->complete();

delete buf;

}

編碼部分:

void encryptor::encrypt(const std::string& name,std::list& password,algorithm::type algo)

// allocate encryption buffer

if (cryptsetattribute(env,crypt_attribute_buffersize,buffer_size))

throw std::runtime_error("could not allocate encryption buffer!");

int n;

int cbytes;

if (!file.eof() && (n = file.read(buf,100)) != 0)

while (!file.eof() && (n = file.read(buf,buffer_size-4096)) != 0)

// flush remaining data

cryptflushdata(env);

cryptpopdata(env,buf,buffer_size,&cbytes);

file.write(buf,cbytes);

// destroy envelope

cryptdestroyenvelope(env);

// close file

file.close();

mlistener->complete();

delete buf;

}

學習的目的是成熟!~

PHP開源專案之YOURLS

yourls是乙個開源的php的程式,可以利用它來構建屬於自己的url縮短服務,yourls還可以整合到wordpress部落格中使用。yourls 的主要功能 公開的 public 任何人都可以用它建立短連線 或者私有的 private,只能你自己使用 可以隨機 順序的 或者自定義。2.修改配置 ...

開源 硬碟加密 6個開源加密貨幣錢包

開源 硬碟加密 沒有加密貨幣錢包,像位元幣和以太坊這樣的加密貨幣將只是另乙個 天上掉餡餅 的想法。這些錢包對於儲存,傳送和接收加密貨幣至關重要。加密貨幣的革命性增長歸因於去中心化的概念,其中網路沒有 機構,每個人都有乙個公平的競爭環境。開源技術是加密貨幣和區塊鏈網路的核心。它使生機勃勃的新興行業能夠...

iPhone開發之 開源專案鏈結

掃瞄wifi資訊 ect 條形碼掃瞄 tcp ip的通訊協議 voip sip three20 google gdata 720全景顯示panoramagl jabber client plblocks image processing json編碼解碼 base64編碼解碼 xml解析 安全儲存使...