使用 GUID 的 RSA 加密和解密

RSA Encryption and Decryption using GUID

任何人都可以使用 public 和私钥

帮助我进行 RSA 加密和解密

RSA是一种非对称加密算法。这意味着它需要 public 和私钥才能加密和解密信息。这通常使用随机生成的密钥来完成。

在技术上是否可以生成 RSA keys from passphrases,尽管这似乎并不是您真正想要的。

A GUID 是一个 128 位整数(16 字节),可用于所有需要唯一标识符的计算机和网络。这样的标识符被复制的概率非常低。

这可能会以某种形式使用 popular symmetric encryption algorithms like AES 来仅使用一个密钥来加密数据,特别是因为 GUID 与 AES 128 位密钥的长度相似。 (尽管实际使用它可能需要一些 finagling,因为一些密码算法需要遵循 特定模式 来获取它们的密钥) 编辑:我刚刚测试过,您可以使用 GUID 作为 128 位 AES 加密密钥,没有花哨的东西。

// create the string that we are going to encrypt
string original = "hello world";

// get a new GUID to use as an encryption key
Guid id =  Guid.NewGuid();

using (Aes myAes = Aes.Create())
{
    // make sure the key size matches what a GUID is (128 bits)
    myAes.KeySize = 128;

    // set the encryption key to use the GUID instead
    myAes.Key = id.ToByteArray();

    // Encrypt the string to an array of bytes.
    byte[] encrypted = EncryptStringToBytes_Aes(original, myAes.Key, myAes.IV);

    // make sure bytes are encrypted
    Console.WriteLine(string.Join(", ", encrypted));

    // Decrypt the bytes to a string.
    string roundtrip = DecryptStringFromBytes_Aes(encrypted, myAes.Key, myAes.IV);

    //Display the original data and the decrypted data.
    Console.WriteLine("Original:   {0}", original);
    Console.WriteLine("Round Trip: {0}", roundtrip);
}

综上所述,为生产和 OPSEC 环境实施有效的加密方案是一项严肃的工作,需要大量信息、背景知识以及对当前密码学环境的深刻理解。我既没有消息灵通,也没有受过足够的教育,无法了解适当的加密标准、技术,以及什么是,什么不能用于有效的加密。在为严肃的项目实施此代码之前,请完成您自己的个人研究。