Neos.IdentityServer 3.0/Neos.IdentityServer.QrCodeNet/ReedSolomon/ReedSolomonEncoder.cs
/// <summary>
/// Encode an array of data codeword with GaloisField 256. 
/// </summary>
/// <param name="dataBytes">Array of data codewords for a single block.</param>
/// <param name="numECBytes">Number of error correction codewords for data codewords</param>
/// <param name="generatorPoly">Cached or newly create GeneratorPolynomial</param>
/// <returns>Return error correction codewords array</returns>
Encode an array of data codeword with GaloisField 256.
Encode an array of data codeword with GaloisField 256 .
internal static byte[] Encode(byte[] dataBytes, int numECBytes, GeneratorPolynomial generatorPoly)
		{
			int dataLength = dataBytes.Length;
			if(generatorPoly == null)
				throw new ArgumentNullException("generator", "GeneratorPolynomial var is null");
			if(dataLength == 0)
				throw new ArgumentException("There is no data bytes to encode");
			if(numECBytes <= 0)
				throw new ArgumentException("No Error Correction bytes");
			int[] toEncode = ConvertToIntArray(dataBytes, dataLength, numECBytes);
			Polynomial generator = generatorPoly.GetGenerator(numECBytes);
			Polynomial dataPoly = new Polynomial(generator.GField, toEncode);
			PolyDivideStruct divideResult = dataPoly.Divide(generator);
			int[] remainderCoeffs = divideResult.Remainder.Coefficients;
			return ConvertTosByteArray(remainderCoeffs, numECBytes);
		}
internal static byte [ ] Encode ( byte [ ] dataBytes , int numECBytes , GeneratorPolynomial generatorPoly ) { int dataLength = dataBytes . Length ; if ( generatorPoly == null ) throw new ArgumentNullException ( " " , " " ) ; if ( dataLength == 0 ) throw new ArgumentException ( " " ) ; if ( numECBytes <= 0 ) throw new ArgumentException ( " " ) ; int [ ] toEncode = ConvertToIntArray ( dataBytes , dataLength , numECBytes ) ; Polynomial generator = generatorPoly . GetGenerator ( numECBytes ) ; Polynomial dataPoly = new Polynomial ( generator . GField , toEncode ) ; PolyDivideStruct divideResult = dataPoly . Divide ( generator ) ; int [ ] remainderCoeffs = divideResult . Remainder . Coefficients ; return ConvertTosByteArray ( remainderCoeffs , numECBytes ) ; }
Encode an array of data codeword with GaloisField 256.
Encode an array of data codeword with GaloisField 256 .
Return error correction codewords array
Return error correction codewords array
dataBytes
byte[]
Array of data codewords for a single block.
Array of data codewords for a single block .
numECBytes
int
Number of error correction codewords for data codewords
Number of error correction codewords for data codewords
generatorPoly
GeneratorPolynomial
Cached or newly create GeneratorPolynomial
Cached or newly create GeneratorPolynomial