Exemple #1
0
 private static string Decode(string s)
 {
     byte[] bytes =
         Base32Convert.FromBase32HexString(s,
                                           Base32FormattingOptions.
                                           InsertTrailingPadding);
     return(Encoding.UTF7.GetString(bytes));
 }
Exemple #2
0
 private static string DecodeOmitPadding(string s)
 {
     byte[] bytes =
         Base32Convert.FromBase32HexString(s,
                                           Base32FormattingOptions.
                                           None);
     return(Encoding.UTF7.GetString(bytes));
 }
Exemple #3
0
        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));
        }
Exemple #4
0
 public void DecodeOmitPadding_PaddingCharacter_throws()
 {
     Assert.Throws <ArgumentException>(
         () => Base32Convert.FromBase32HexString("my======", Base32FormattingOptions.None));
 }
Exemple #5
0
 public void DecodeOmitPadding_null_throws()
 {
     Assert.Throws <ArgumentNullException>(
         () => Base32Convert.FromBase32HexString(null, Base32FormattingOptions.None));
 }
Exemple #6
0
 public void DecodeOmitPadding_CharacterNotInAlphabet_throws()
 {
     Assert.Throws <ArgumentException>(
         () => Base32Convert.FromBase32HexString("#y", Base32FormattingOptions.None));
 }
Exemple #7
0
 public void Decode_WrongNumberOfPaddingCharacters_throws()
 {
     Assert.Throws <ArgumentException>(
         () => Base32Convert.FromBase32HexString("my=====", Base32FormattingOptions.InsertTrailingPadding));
 }
Exemple #8
0
 public void DecodeOmitPadding_WrongNumberOfCharacters_6_throws()
 {
     Assert.Throws <ArgumentException>(
         () => Base32Convert.FromBase32HexString("123456", Base32FormattingOptions.None));
 }
Exemple #9
0
 public void Decode_null_throws()
 {
     Assert.Throws <ArgumentNullException>(
         () => Base32Convert.FromBase32HexString(null, Base32FormattingOptions.InsertTrailingPadding));
 }
Exemple #10
0
 public void Decode_MisplacedPaddingCharacter_throws()
 {
     Assert.Throws <ArgumentException>(
         () => Base32Convert.FromBase32HexString("m=y======", Base32FormattingOptions.InsertTrailingPadding)
         );
 }
Exemple #11
0
 public void Decode_CharacterNotInAlphabet_throws()
 {
     Assert.Throws <ArgumentException>(
         () => Base32Convert.FromBase32HexString("#y======", Base32FormattingOptions.InsertTrailingPadding)
         );
 }