reed Solomon255223 Protect() - > Result<Bytes, string>- 수신자
- Bytes
- 최소 인자 수
- 0
- 최대 인자 수
- 0
Declaration and parameters
링크사용 조건
기본 포함 · 미정
Import std.bytes in language mode 5.21.
The current compiler selects std/bytes.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.
수신자
Bytes
매개변수 제약
Bytes.reedSolomon255223Protect accepts between 1 and 14614305 input bytes. Empty input and larger input return Err with a string.
Input bytes are partitioned into consecutive 223-byte data chunks. The final chunk is padded with zero bytes to 223 bytes.
Each output codeword contains its 223 data bytes followed by 32 parity bytes. Codewords are concatenated in input order.
The result contains 255 times the ceiling of input length divided by 223 bytes. At most 65535 codewords are produced.
Field arithmetic uses GF256 with primitive polynomial 0x11d and primitive element 2. Generator roots are the powers of that element from 0 through 31.
Treat the first data byte as the highest-degree coefficient. Parity is the 32-byte remainder after multiplying the data polynomial by x to the power 32.
The output contains no original length or additional framing. Callers must retain the input length to distinguish padding from original trailing zero bytes.
The operation generates parity bytes. It does not detect or correct corruption in existing codewords.
The receiver evaluates once and remains unchanged. Input bounds are checked before output allocation and failure exposes no codeword prefix.
관련 규칙 · Protect data with systematic Reed-Solomon codewords →결과
The declared result type is Result<Bytes, string>.
효과
실패
Result and effects
링크Protect nonempty data with systematic 255-byte codewords containing 223 data bytes and 32 parity bytes. At most 65535 codewords are produced.
Resolved contracts
링크Related entries
링크Protect data with systematic Reed-Solomon codewords
링크Protect data with systematic Reed-Solomon codewords
Bytes.reedSolomon255223Protect accepts between 1 and 14614305 input bytes. Empty input and larger input return Err with a string.
Input bytes are partitioned into consecutive 223-byte data chunks. The final chunk is padded with zero bytes to 223 bytes.
Each output codeword contains its 223 data bytes followed by 32 parity bytes. Codewords are concatenated in input order.
The result contains 255 times the ceiling of input length divided by 223 bytes. At most 65535 codewords are produced.
Field arithmetic uses GF256 with primitive polynomial 0x11d and primitive element 2. Generator roots are the powers of that element from 0 through 31.
Treat the first data byte as the highest-degree coefficient. Parity is the 32-byte remainder after multiplying the data polynomial by x to the power 32.
The output contains no original length or additional framing. Callers must retain the input length to distinguish padding from original trailing zero bytes.
The operation generates parity bytes. It does not detect or correct corruption in existing codewords.
The receiver evaluates once and remains unchanged. Input bounds are checked before output allocation and failure exposes no codeword prefix.
이유
A field definition and systematic layout make parity interoperable. Keeping the original length outside the codeword avoids silently guessing which trailing zero bytes belong to the payload.
Protect a zero byte with zero padding and parity
링크import std.bytes { Bytes }import std.ioimport std.testlet encoded = test.assertOk(test.assertOk(Bytes.fromArray([0])).reedSolomon255223Protect())io.writeLine("{encoded.toArray().length}")io.writeLine(encoded.slice(0, 4).toHex())io.writeLine(encoded.slice(223, 255).toHex())
255
00000000
0000000000000000000000000000000000000000000000000000000000000000
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
255000000000000000000000000000000000000000000000000000000000000000000000000
Reject empty data before creating codewords
링크import std.bytes { Bytes }import std.iomatch (Bytes.empty().reedSolomon255223Protect()) {case Err(_) => io.writeLine("empty data rejected")case Ok(_) => io.writeLine("accepted")}
empty data rejected
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
empty data rejected
Emit the specified parity for a nonzero payload
링크import std.ioimport std.testlet encoded = test.assertOk("hello".encodeUtf8().reedSolomon255223Protect())io.writeLine(encoded.slice(0, 5).toHex())io.writeLine(encoded.slice(223, 255).toHex())
68656c6c6f
c7a146d71a5245bf94210961b0acac5f4358ac66cf234be24bcea41117eeb5fd
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
68656c6c6fc7a146d71a5245bf94210961b0acac5f4358ac66cf234be24bcea41117eeb5fd