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)); }
private void _Upsert(string key, byte[] value) { var vsn = Versioned.TryWrap(_version, value); base.Upsert(key, Convert.ToBase64String(vsn)); }
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_Null_Value() { Assert.Throws <Versioned.WrapFailedException>(() => Versioned.TryWrap("1.01.0", null)); }
public void Wrap_Empty_Version() { var a = Versioned.TryUnwrap(Versioned.TryWrap("", new byte[] { 1, 2, 3 })); Assert.AreEqual("", a.Version); }
public void Wrap_Null_Version() { Assert.Throws <Versioned.WrapFailedException>(() => Versioned.TryWrap(null, new byte[] { 1, 2, 3 })); }