Documentation ¶
Overview ¶
*
- @Author: Bizzaro Francesco <d33pblue>
- @Date: 2020-May-01
- @Project: Proof of Evolution
- @Filename: file_exists.go
- @Last modified by: d33pblue
- @Last modified time: 2020-May-09
- @Copyright: 2020
Index ¶
- func CheckSignature(sign, hashed string, addr Addr) bool
- func CompareHashes(h1, h2 string) bool
- func CompareSlices(h1, h2 []byte) bool
- func DownloadFile(url string, filepath string) error
- func ExportPrivateKeyAsPemStr(key Key) string
- func ExportPublicKeyAsPemStr(key Key) string
- func ExportPublicKeyAsPemStr2(pubkey *rsa.PublicKey) string
- func FetchDataFromUrl(url string) []byte
- func FileExists(filename string) bool
- func GetSignatureFromHash(hashed string, key Key) []byte
- func LoadPublicKeyFromPemStr(pemStr []byte) (*rsa.PublicKey, error)
- type Addr
- type HashBuilder
- type Key
- type SignBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSignature ¶
Check the signature of some data from the hash and a public key.
func CompareHashes ¶
func CompareSlices ¶
func DownloadFile ¶
Downloads a url to a local file, writing as it downloads and not loading the whole file into memory.
func ExportPrivateKeyAsPemStr ¶
Returns the private key as string in pem format.
func ExportPublicKeyAsPemStr ¶
Returns the public key as string in pem format.
func ExportPublicKeyAsPemStr2 ¶
Returns the public key as string in pem format.
func FetchDataFromUrl ¶
Returns the data at a url as []byte
func FileExists ¶
true <=> the file of [filename] path exists. That file must not be a folder.
func GetSignatureFromHash ¶
Signs data from the hash, using a private key.
Types ¶
type HashBuilder ¶
type HashBuilder struct {
// contains filtered or unexported fields
}
HashBuilder can be used to collect data and obtain the hash of the total bytes.
func (*HashBuilder) Add ¶
func (self *HashBuilder) Add(data interface{})
Adds some data to the HashBuilder. The data can be of any type and is read as []byte.
func (*HashBuilder) GetHash ¶
func (self *HashBuilder) GetHash() []byte
Returns the hash of all the collected data of an HashBuilder.
type Key ¶
type Key *rsa.PrivateKey // type for private key
func GenerateKey ¶
Generates a couple of public and private keys. The public key is stored inside; in order to extract it you can use GetAddr(key)
func LoadPrivateKeyFromPemStr ¶
Create a Key from the bytes of a private key in pem format.
type SignBuilder ¶
type SignBuilder struct {
// contains filtered or unexported fields
}
Can be used as builder to store data and obtain a signature.
func (*SignBuilder) Add ¶
func (self *SignBuilder) Add(data interface{})
Adds data to the SignBuilder. The data can be of any type and is read in []byte.
func (*SignBuilder) GetSignature ¶
func (self *SignBuilder) GetSignature(key Key) []byte
Returns the signature of the collection of the submitted data of a SignBuilder.