...

Source file src/cuelang.org/go/pkg/crypto/sha512/sha512.go

Documentation: cuelang.org/go/pkg/crypto/sha512

     1  // Copyright 2018 The CUE Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Copyright 2018 The Go Authors. All rights reserved.
    16  // Use of this source code is governed by a BSD-style
    17  // license that can be found in the LICENSE file.
    18  
    19  package sha512
    20  
    21  import "crypto/sha512"
    22  
    23  const (
    24  	// Size is the size, in bytes, of a SHA-512 checksum.
    25  	Size = 64
    26  
    27  	// Size224 is the size, in bytes, of a SHA-512/224 checksum.
    28  	Size224 = 28
    29  
    30  	// Size256 is the size, in bytes, of a SHA-512/256 checksum.
    31  	Size256 = 32
    32  
    33  	// Size384 is the size, in bytes, of a SHA-384 checksum.
    34  	Size384 = 48
    35  
    36  	// BlockSize is the block size, in bytes, of the SHA-512/224,
    37  	// SHA-512/256, SHA-384 and SHA-512 hash functions.
    38  	BlockSize = 128
    39  )
    40  
    41  // Sum512 returns the SHA512 checksum of the data.
    42  func Sum512(data []byte) []byte {
    43  	a := sha512.Sum512(data)
    44  	return a[:]
    45  }
    46  
    47  // Sum384 returns the SHA384 checksum of the data.
    48  func Sum384(data []byte) (sum384 []byte) {
    49  	a := sha512.Sum384(data)
    50  	return a[:]
    51  }
    52  
    53  // Sum512_224 returns the Sum512/224 checksum of the data.
    54  func Sum512_224(data []byte) (sum224 []byte) {
    55  	a := sha512.Sum512_224(data)
    56  	return a[:]
    57  }
    58  
    59  // Sum512_256 returns the Sum512/256 checksum of the data.
    60  func Sum512_256(data []byte) (sum256 []byte) {
    61  	a := sha512.Sum512_256(data)
    62  	return a[:]
    63  }
    64  

View as plain text