Sha256: c4f9152263c8f9e3bf802e923d23b2b1461cb6223782b32a50c81c6fd1ae7ce6

Contents?: true

Size: 615 Bytes

Versions: 16

Compression:

Stored size: 615 Bytes

Contents

package http

import (
	"crypto/md5"
	"encoding/base64"
	"fmt"
	"io"
)

// computeMD5Checksum computes base64 md5 checksum of an io.Reader's contents.
// Returns the byte slice of md5 checksum and an error.
func computeMD5Checksum(r io.Reader) ([]byte, error) {
	h := md5.New()
	// copy errors may be assumed to be from the body.
	_, err := io.Copy(h, r)
	if err != nil {
		return nil, fmt.Errorf("failed to read body: %w", err)
	}

	// encode the md5 checksum in base64.
	sum := h.Sum(nil)
	sum64 := make([]byte, base64.StdEncoding.EncodedLen(len(sum)))
	base64.StdEncoding.Encode(sum64, sum)
	return sum64, nil
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/aws/smithy-go/transport/http/md5_checksum.go