zl程序教程

您现在的位置是:首页 >  后端

当前栏目

[C++] 异或加密

C++加密 异或
2023-09-11 14:13:59 时间
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;
}