public void Wrap_UnWrap() { var data = "Hexatすたじお☺"; var version = "1.0.0"; var ret = Versioned.TryWrap(version, Encoding.UTF8.GetBytes(data)); var decrypted = Versioned.TryUnwrap(ret); Assert.AreEqual(version, decrypted.Version); Assert.AreEqual(data, Encoding.UTF8.GetString(decrypted.Data)); }
private byte[] GetBytes(string key) { if (!HasKey(key)) { return(null); } var base64 = base.GetString(key); var bytes = Convert.FromBase64String(base64); var vsn = Versioned.TryUnwrap(bytes); return(_crypterProvider(vsn.Version).TryDecrypt(vsn.Data)); }
public void UnWrap_Invalid_Data() { var d = new byte[] { 1, 2, 3, 3, 4, 5 }; Assert.Throws <Versioned.UnwrapFailedException>(() => Versioned.TryUnwrap(d)); }
public void UnWrap_Null_Data() { Assert.Throws <Versioned.UnwrapFailedException>(() => Versioned.TryUnwrap(null)); }
public void Wrap_Empty_Value() { var a = Versioned.TryUnwrap(Versioned.TryWrap("1.01.0", new byte[0])); Assert.AreEqual(0, a.Data.Length); }
public void Wrap_Empty_Version() { var a = Versioned.TryUnwrap(Versioned.TryWrap("", new byte[] { 1, 2, 3 })); Assert.AreEqual("", a.Version); }