C/C++ 异或加密实现代码

一段使用C++开发实现的异或加解密方法,可用于对特定字符串数据进行数据加解密操作,方便后期调用。

std::string Encrypt(std::string content, std::string secretKey)
{
    for (UINT i = 0; i < content.length(); i++)
    {
        content[i] ^= secretKey[i % secretKey.length()];
    }
 
    return content;
}
 
std::string Decrypt(std::string data, std::string secretKey)
{
    for (UINT i = 0; i < data.length(); i++)
    {
        data[i] ^= secretKey[i % secretKey.length()];
    }
 
    return data;
}
posted @ 2021-08-01 14:39  lyshark  阅读(912)  评论(0编辑  收藏  举报

loading... | loading...
博客园 - 开发者的网上家园