본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    라이브러리 · std.bytes

    Bytes.sha512

    Computes the SHA-512 digest of this byte sequence.

    sha512() -> Bytes
    수신자
    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.crc32 returns the unsigned CRC-32/ISO-HDLC value as an int from 0 through 4294967295.

    CRC-32 uses width 32, polynomial 0x04c11db7, reflected input and output, initial value 0xffffffff, and final XOR 0xffffffff.

    Bytes.sha256 and Bytes.sha512 implement FIPS 180-4 and return 32 and 64 digest bytes respectively.

    Bytes.hmacSha256 uses its receiver as the key and its argument as the message. It returns the 32-byte HMAC-SHA-256 value from RFC 2104.

    HMAC hashes a key longer than the 64-byte SHA-256 block before zero-padding it. Empty keys and messages are valid.

    Empty input is valid for every checksum and digest. CRC-32 of empty input is zero.

    These operations process stored bytes without decoding or normalization. Inputs remain unchanged and correctly typed calls have no data-dependent failure.

    The receiver and any message argument evaluate once in that order. No external state, random input, or I/O affects the result.

    Use toHex or toBase64 on a digest when a text encoding is required. Those encodings are separate from the digest bytes.

    결과

    The declared result type is Bytes.

    효과

    실패

    Result and effects

    링크

    Return the 64-byte SHA-512 digest of the exact receiver bytes.

    Resolved contracts

    링크

    Related entries

    링크

    std.bytes →

    Compute interoperable checksums and digests

    링크
    규칙topaz.stdlib.contract.bytes-digests.rule

    Compute interoperable checksums and digests

    Bytes.crc32 returns the unsigned CRC-32/ISO-HDLC value as an int from 0 through 4294967295.

    CRC-32 uses width 32, polynomial 0x04c11db7, reflected input and output, initial value 0xffffffff, and final XOR 0xffffffff.

    Bytes.sha256 and Bytes.sha512 implement FIPS 180-4 and return 32 and 64 digest bytes respectively.

    Bytes.hmacSha256 uses its receiver as the key and its argument as the message. It returns the 32-byte HMAC-SHA-256 value from RFC 2104.

    HMAC hashes a key longer than the 64-byte SHA-256 block before zero-padding it. Empty keys and messages are valid.

    Empty input is valid for every checksum and digest. CRC-32 of empty input is zero.

    These operations process stored bytes without decoding or normalization. Inputs remain unchanged and correctly typed calls have no data-dependent failure.

    The receiver and any message argument evaluate once in that order. No external state, random input, or I/O affects the result.

    Use toHex or toBase64 on a digest when a text encoding is required. Those encodings are separate from the digest bytes.

    이유

    Named standard algorithms must agree with independent implementations. Keeping digest bytes separate from their text representation makes the same digest usable in binary and text formats.

    Match established checksum and hash vectors

    링크
    main.tpzMatch established checksum and hash vectors플레이그라운드 열기 →
    1. import std.bytes { Bytes }
    2. import std.io
    3. io.writeLine("{Bytes.empty().crc32()}")
    4. let checksum = "123456789".encodeUtf8().crc32()
    5. io.writeLine("{checksum}")
    6. io.writeLine("abc".encodeUtf8().sha256().toHex())
    7. io.writeLine("abc".encodeUtf8().sha512().toHex())
    8. io.writeLine("key".encodeUtf8().hmacSha256("The quick brown fox jumps over the lazy dog".encodeUtf8()).toHex())
    기대 출력종료 코드 0
    0
    3421780262
    ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
    ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
    f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. 0
    2. 3421780262
    3. ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
    4. ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
    5. f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8

    메뉴

    다운로드 →