private static unsafe ulong DecodeBlock(char *codeBuffer, DecodingBlock block) { ulong receptor = 0; // receives imprinted var imprintOffset = 0; for (int i = 0; i < block.CodeLength; i++) { var code = *(codeBuffer + i); if (IsCutoffCharacter(code)) { continue; } var data = DecodeTable[code]; ulong imprinted = 0; imprinted |= data; imprinted <<= imprintOffset; receptor |= imprinted; imprintOffset += ENCODING_BITS; } return(receptor); }
internal static bool MarkupBlocks(ref DecodingBlock current, List <DecodingBlock> accumulator, string input, bool finalize) { var inputLength = input.Length; for (int i = 0; i < inputLength; i++) { var is_final = finalize && (i == inputLength - 1); // is it the final character? var c = input[i]; bool eob; try { // verify next character against block descriptor // and adjust block parameters eob = current.AddCode(c, is_final); // end of block } catch (InvalidOperationException iox) { throw new ArgumentException(DECODE_ERROR_MESSAGE, nameof(input), iox); // invalid code(s) added to the block } if (eob) { // if block is finished accumulator.Add(current); // add to the accumulator current = new DecodingBlock(); // and start a new block } } return(accumulator.Any()); }
private static byte[] FromBase32StringInternal(string input) { var accumulator = new List <DecodingBlock>(); var current = new DecodingBlock(); MarkupBlocks(ref current, accumulator, input, true); return(DecodeBlockSequence(input, accumulator)); }