當前位置:首頁 » 編程軟體 » libtomcrypt編譯

libtomcrypt編譯

發布時間: 2023-02-17 02:21:24

㈠ 請教BCB里的Base64加密有沒有能直接加密文件流的方法

下載 TomCrypt 通用加密庫
編譯出 Lib
--------------------------------------------------------------------
// 調用

String a = "";

File2Text(&a, "c:\\1.jpg");
Text2File("c:\\2.jpg", &a);
---------------------------------------------------------------------
// 功能實現,自己在函數內加上一些可靠性驗證也就差不多了

int __fastcall Bin2Text(String* OutText, TMemoryStream* pMS)
{
/* 二進制流數據轉換為 base64 碼 */

// 初始化輸出字元串
*OutText = "";
// 計算輸出字元串長度
unsigned long OutStringSize = 4 * (((unsigned long)pMS->Size + 2) / 3) + 1;
// 設置輸出字元串長度
OutText->SetLength( OutStringSize );
// 置內存流初始點
pMS->Position = 0;
// 開始轉換
int Result = base64_encode (
(unsigned char*)pMS->Memory, (unsigned long)pMS->Size,
(unsigned char*)OutText->c_str(), &OutStringSize );
// 返回轉換結果
return Result;
}
//---------------------------------------------------------------------------

int __fastcall File2Text(String *OutText, String Filename)
{
/* 輸入文件轉換為 base64 碼 */

// 創建內存流
TMemoryStream* pMS = new TMemoryStream;
// 載入文件
pMS->LoadFromFile(Filename);
// 置指針初始位置
pMS->Position = 0;
// 開始轉換,並將輸出內容保存到 OutText
int Result = Bin2Text(OutText, pMS);
// 刪除內存對象
delete pMS;
// 反饋結果
return Result;
}
//---------------------------------------------------------------------------

int __fastcall Text2File(String Filename, String* InText)
{
/* base64 碼轉換為 二進制文件 */

// 創建內存流
TMemoryStream* pMS = new TMemoryStream;
// 通過輸入的 base64 指針信息轉換為 二進制流
int Result = Text2Bin(pMS, InText);
// 置指針初始位值,保存文件
pMS->Position = 0;
pMS->SaveToFile(Filename);
// 刪除對象
delete pMS;
// 反饋結果
return Result;
}
//---------------------------------------------------------------------------

int __fastcall Text2Bin(TMemoryStream* pMS, String* InText)
{
/* base64 轉換為二進制流 */

// 獲得 base64 長度
unsigned long* pStrSize = new unsigned long;
*pStrSize = InText->Length();
// 獲得 base64 長度
unsigned long StrSize = InText->Length();
// 清除對象信息
pMS->Clear();
// 設置長度
pMS->Size = StrSize;
// 轉換
int Result = base64_decode (
(unsigned char*)InText->c_str(),
StrSize,
(unsigned char*)pMS->Memory,
pStrSize
);
// 重新設置實際長度
pMS->Size = *pStrSize;
// 刪除臨時對象
delete pStrSize;
// 置內存流初始位置
pMS->Position = 0;
// 反饋信息
return Result;
}
//---------------------------------------------------------------------------

㈡ 在ubuntu 10.04下編譯buildroot-v23434提示stdio.h:286: error: expected declaration specifiers錯誤

下載buildroot穩定版本V2012.02試試

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:748
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:1012
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:718
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:878
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:774
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1127
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:350
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:229
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:911
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:875