Exemplo n.º 1
0
 internal Base64Encoding(char[] alphabet, char padding, string encodingName, bool verify)
 {
     if (verify)
     {
         if (alphabet == null)
         {
             throw new ArgumentNullException("alphabet", "alphabet is null");
         }
         if (encodingName == null)
         {
             throw new ArgumentNullException("encodingName", "encodingName is null");
         }
         if (alphabet.Length != 64)
         {
             throw new ArgumentOutOfRangeException("alphabet", "size of alphabet is not 64");
         }
         if (ArrayFunctions.IsArrayDuplicate(alphabet))
         {
             throw new ArgumentException("alphabet", "alphabet contains duplicated items");
         }
         if (ArrayFunctions.IsArrayContains(alphabet, padding))
         {
             throw new ArgumentException("padding", "padding already existed in alphabet");
         }
     }
     this.alphabet     = (char[])alphabet.Clone();
     this.padding      = padding;
     this.encodingName = encodingName;
     this.InitAlgorithm(this.alphabet, this.padding);
 }
Exemplo n.º 2
0
 internal Base16Encoding(char[] alphabet, string encodingName, bool verify)
 {
     if (verify)
     {
         if (alphabet == null)
         {
             throw new ArgumentNullException("alphabet", "alphabet is null");
         }
         if (encodingName == null)
         {
             throw new ArgumentNullException("encodingName", "encodingName is null");
         }
         if (alphabet.Length != 16)
         {
             throw new ArgumentOutOfRangeException("alphabet", "size of alphabet is not 16");
         }
         if (ArrayFunctions.IsArrayDuplicate(alphabet))
         {
             throw new ArgumentException("alphabet", "alphabet contains duplicated items");
         }
     }
     this.alphabet     = (char[])alphabet.Clone();
     this.encodingName = encodingName;
     this.InitAlgorithm(this.alphabet);
 }