public void BinaryToBase64EmptyByteArrTest() { var emptyArr = new byte[] { }; string base64 = Utilities.BinaryToBase64(emptyArr); var decrypted = Utilities.Base64ToBinary(base64, " "); Assert.IsEmpty(decrypted); }
public void BinaryToBase64UrlSafeNoPaddingTest() { var aliceSk = new byte[] { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a }; var base64 = Utilities.BinaryToBase64(aliceSk, Utilities.Base64Variant.UrlSafeNoPadding); var decrypted = Utilities.Base64ToBinary(base64, null, Utilities.Base64Variant.UrlSafeNoPadding); Assert.AreEqual(aliceSk, decrypted); }
public void BinaryToBase64IgnoreSpaceTest() { var aliceSk = new byte[] { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a }; string base64 = Utilities.BinaryToBase64(aliceSk); string editedBase64 = ""; foreach (char item in base64) { editedBase64 += $"{item} "; } var decrypted = Utilities.Base64ToBinary(editedBase64, " "); Assert.AreEqual(aliceSk, decrypted); }
public void BinaryToBase64NullTest() { Assert.That(() => Utilities.BinaryToBase64(null), Throws.Exception.TypeOf <ArgumentNullException>()); }