private static string Decode(string s) { byte[] bytes = Base32Convert.FromBase32HexString(s, Base32FormattingOptions. InsertTrailingPadding); return(Encoding.UTF7.GetString(bytes)); }
private static string DecodeOmitPadding(string s) { byte[] bytes = Base32Convert.FromBase32HexString(s, Base32FormattingOptions. None); return(Encoding.UTF7.GetString(bytes)); }
public static void EncodeThenDecodeNoPadding(IEnumerator[] a) { List <byte> octets = new List <byte>(); for (int j = 1; j < a.Length; j++) { octets.Add((byte)a[j].Current); } byte[] result = Base32Convert.FromBase32HexString( Base32Convert.ToBase32HexString(octets, Base32FormattingOptions.None), Base32FormattingOptions.None); Assert.IsTrue(SameContent(result, octets, Comparer <byte> .Default)); }
public void DecodeOmitPadding_PaddingCharacter_throws() { Assert.Throws <ArgumentException>( () => Base32Convert.FromBase32HexString("my======", Base32FormattingOptions.None)); }
public void DecodeOmitPadding_null_throws() { Assert.Throws <ArgumentNullException>( () => Base32Convert.FromBase32HexString(null, Base32FormattingOptions.None)); }
public void DecodeOmitPadding_CharacterNotInAlphabet_throws() { Assert.Throws <ArgumentException>( () => Base32Convert.FromBase32HexString("#y", Base32FormattingOptions.None)); }
public void Decode_WrongNumberOfPaddingCharacters_throws() { Assert.Throws <ArgumentException>( () => Base32Convert.FromBase32HexString("my=====", Base32FormattingOptions.InsertTrailingPadding)); }
public void DecodeOmitPadding_WrongNumberOfCharacters_6_throws() { Assert.Throws <ArgumentException>( () => Base32Convert.FromBase32HexString("123456", Base32FormattingOptions.None)); }
public void Decode_null_throws() { Assert.Throws <ArgumentNullException>( () => Base32Convert.FromBase32HexString(null, Base32FormattingOptions.InsertTrailingPadding)); }
public void Decode_MisplacedPaddingCharacter_throws() { Assert.Throws <ArgumentException>( () => Base32Convert.FromBase32HexString("m=y======", Base32FormattingOptions.InsertTrailingPadding) ); }
public void Decode_CharacterNotInAlphabet_throws() { Assert.Throws <ArgumentException>( () => Base32Convert.FromBase32HexString("#y======", Base32FormattingOptions.InsertTrailingPadding) ); }