public void EncryptDecrypt_WithSalt_WithAutoCreateKey_L128_Test() { var key = DesFactory.GenerateKey(DesTypes.TripleDES128); var function = DesFactory.Create(DesTypes.TripleDES128, key); var cryptoVal0 = function.Encrypt("实现中华民族伟大复兴的中国梦", "123412341234"); var cryptoVal1 = function.Decrypt(cryptoVal0.CipherData, "123412341234"); cryptoVal1.GetOriginalDataDescriptor().GetString().ShouldBe("实现中华民族伟大复兴的中国梦"); var cryptoVal2 = function.Decrypt(BaseConv.ToBase64(cryptoVal0.CipherData), "123412341234", CipherTextTypes.Base64Text); cryptoVal2.GetOriginalDataDescriptor().GetString().ShouldBe("实现中华民族伟大复兴的中国梦"); }
public void EncryptDecrypt_WithAutoCreateKey_Test() { var key = DesFactory.GenerateKey(); var function = DesFactory.Create(DesTypes.DES, key); var cryptoVal0 = function.Encrypt("image"); var cryptoVal1 = function.Decrypt(cryptoVal0.CipherData); cryptoVal1.GetOriginalDataDescriptor().GetString().ShouldBe("image"); var cryptoVal2 = function.Decrypt(BaseConv.ToBase64(cryptoVal0.CipherData), CipherTextTypes.Base64Text); cryptoVal2.GetOriginalDataDescriptor().GetString().ShouldBe("image"); }
public void EncryptDecrypt_WithSalt_Test() { var key = DesFactory.GenerateKey(DesTypes.DES, "alexinea", "forerunner", Encoding.UTF8); var function = DesFactory.Create(DesTypes.DES, key); var cryptoVal0 = function.Encrypt("image", "123412341234"); BaseConv.ToBase64(cryptoVal0.CipherData).ShouldBe("s4h5u8hA/2Y="); var cryptoVal1 = function.Decrypt(cryptoVal0.CipherData, "123412341234"); cryptoVal1.GetOriginalDataDescriptor().GetString().ShouldBe("image"); var cryptoVal2 = function.Decrypt(BaseConv.ToBase64(cryptoVal0.CipherData), "123412341234", CipherTextTypes.Base64Text); cryptoVal2.GetOriginalDataDescriptor().GetString().ShouldBe("image"); }
public void EncryptDecrypt_L192_Test() { var key = DesFactory.GenerateKey(DesTypes.TripleDES192, "alexinea&#%12!", "forerunner", Encoding.UTF8); var function = DesFactory.Create(DesTypes.TripleDES192, key); var cryptoVal0 = function.Encrypt("image"); BaseConv.ToBase64(cryptoVal0.CipherData).ShouldBe("Y6tAf/GrLx8="); var cryptoVal1 = function.Decrypt(cryptoVal0.CipherData); cryptoVal1.GetOriginalDataDescriptor().GetString().ShouldBe("image"); var cryptoVal2 = function.Decrypt(BaseConv.ToBase64(cryptoVal0.CipherData), CipherTextTypes.Base64Text); cryptoVal2.GetOriginalDataDescriptor().GetString().ShouldBe("image"); }