cryptography

package module
v0.0.0-...-5f0123e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 7 Imported by: 0

README

cryptography

Go Reference Go Report Card

Documentation

Index

Examples

Constants

View Source
const SHA256Size = 32
View Source
const SHA512Size = 64

Variables

This section is empty.

Functions

This section is empty.

Types

type SHA256

type SHA256 []byte

func ParseSHA256Sum

func ParseSHA256Sum(s string) (SHA256, error)

ParseSHA256Sum parses a hex encoded string of an SHA256 sum.

func SHA256Sum

func SHA256Sum(data []byte) SHA256

SHA256Sum returns the SHA256 checksum of data.

Example
package main

import (
	"fmt"

	"git.gorbe.io/go/cryptography"
)

func main() {

	d := []byte{0}

	s := cryptography.SHA256Sum(d)

	fmt.Printf("%s", s)
}
Output:

6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d

func SHA256SumFile

func SHA256SumFile(path string) (SHA256, error)

SHA256SumFile returns the SHA256 checksum of the file in path. Uses io.Copy() to be usable on large files.

func SHA256SumReader

func SHA256SumReader(r io.Reader) (SHA256, error)

SHA256SumReader returns the SHA256 checksum of the data read from r. Uses io.Copy() to be usable on large files.

func (SHA256) Check

func (s SHA256) Check(data []byte) bool

Check returns whether the SHA256 sum of data if equal to s.

func (SHA256) String

func (s SHA256) String() string

String returns the hexadecimal encoding of s.

type SHA512

type SHA512 []byte

func ParseSHA512Sum

func ParseSHA512Sum(s string) (SHA512, error)

ParseSHA512Sum parses a hex encoded string of an SHA512 sum.

func SHA512Sum

func SHA512Sum(data []byte) SHA512

SHA512Sum returns the SHA512 checksum of data.

Example
package main

import (
	"fmt"

	"git.gorbe.io/go/cryptography"
)

func main() {

	d := []byte{0}

	s := cryptography.SHA512Sum(d)

	fmt.Printf("%s", s)
}
Output:

b8244d028981d693af7b456af8efa4cad63d282e19ff14942c246e50d9351d22704a802a71c3580b6370de4ceb293c324a8423342557d4e5c38438f0e36910ee

func SHA512SumFile

func SHA512SumFile(path string) (SHA512, error)

SHA512SumFile returns the SHA512 checksum of the file in path. Uses io.Copy() to be usable on large files.

func SHA512SumReader

func SHA512SumReader(r io.Reader) (SHA512, error)

SHA512SumReader returns the SHA512 checksum of the data read from r. Uses io.Copy() to be usable on large files.

func (SHA512) Check

func (s SHA512) Check(data []byte) bool

Check returns whether the SHA512 sum of data if equal to s.

func (SHA512) String

func (s SHA512) String() string

String returns the hexadecimal encoding of s.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL