这个加密等级足够安全吗?或者有人可以反汇编我的二进制文件以找到 key 和 IV?我正在使用它来解密许可证文件,因此它不能轻易被破解是非常重要的。
internal static class Encryptor
{
// Actual values are put here in my source
private static readonly byte[] Key = { 0, 0, 0, 0, 0, 0, 0, 0 };
private static readonly byte[] Iv = { 0, 0, 0, 0, 0, 0, 0, 0 };
internal static String Encrypt(string source)
{
var des = new DESCryptoServiceProvider();
var enc = des.CreateEncryptor(Key, Iv);
var b = Encoding.ASCII.GetBytes(source);
var encId = enc.TransformFinalBlock(b, 0, b.Length);
return Convert.ToBase64String(encId);
}
internal static string Decrypt(string encrypted)
{
var des = new DESCryptoServiceProvider();
var dec = des.CreateDecryptor(Key, Iv);
var b = Convert.FromBase64String(encrypted);
var decId = dec.TransformFinalBlock(b, 0, b.Length);
return Encoding.ASCII.GetString(decId);
}
}
这类似于 this question和 this one ,但似乎都没有明确的答案(据我所知 - 我承认我是这个主题的完全初学者)。请指教。 :)
最佳答案
是的,这很容易坏。任何了解 Reflector(或 ILSpy、dotPeek 或...)等工具的开发人员都可以轻松识别加密函数并找到您的 key 。拥有该程序集的人甚至可以直接调用 Decrypt
,而不必为提取 key 而烦恼。
它足够安全吗?这取决于,只有你能回答。如果这是为了许可,就相当于在盒子上贴了一张标签,上面写着“不要复制我的软件”。另一方面,为经验丰富且意志坚定的攻击者制定难以破解的强大许可方案是一项艰巨的任务,您可能需要考虑是否值得付出努力。就个人而言,我会投入时间让软件变得如此出色,以至于人们愿意为它付费,而不是阻止少数坏人在未经许可的情况下使用它。
关于c# - 在源代码中存储加密 key 有多安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7785543/