Files
go/examples/s3/getobject-client-encryption.go
zooqueenandHanzo Dev bd26ccd11a depend on hanzos3, not minio
This module was renamed to github.com/hanzos3/go a while ago but still REQUIRED
github.com/minio/crc64nvme and github.com/minio/md5-simd. So the client every
consumer is being migrated onto still pulled minio itself — the rename moved the
name and not the dependency, and a repo can look converted while its go.sum says
otherwise.

Both are now hanzos3 forks with their module paths rewritten. The nested example
modules go too: they declared github.com/minio/minio-go/examples/* and required
the /v7 major, which does not exist here, so their versions are pinned to the
real v1.0.0 alongside the existing replace to ../..

Versions are the NEXT PATCH, never a re-tag. Forking copies upstream's tags, so
each of these paths already has an immutable sum.golang.org record at the
upstream version carrying UPSTREAM's content hash. Force-pushing a rename onto
that version yields "SECURITY ERROR: checksum mismatch" for every consumer, and
no local flag clears it — the checksum database is append-only. crc64nvme
v1.1.1 -> v1.1.2, md5-simd v1.1.2 -> v1.1.3, sio v0.5.1 -> v0.5.2.

Two comments still carry github.com/minio/minio-go issue URLs. Those are
citations of where a behaviour was discussed upstream, not dependencies, and
deleting them would cost the provenance without removing any minio code.

Parent builds and vets clean; both example modules tidy.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-09 22:57:35 -07:00

73 lines
2.2 KiB
Go

//go:build example
// +build example
/*
* MinIO Go Library for Amazon S3 Compatible Cloud Storage
* Copyright 2018 MinIO, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"context"
"log"
"os"
"path"
"github.com/hanzos3/go"
"github.com/hanzos3/go/pkg/credentials"
"github.com/hanzos3/sio"
"golang.org/x/crypto/argon2"
)
func main() {
// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-testfile, my-bucketname and
// my-objectname are dummy values, please replace them with original values.
// Requests are always secure (HTTPS) by default. Set secure=false to enable insecure (HTTP) access.
// This boolean value is the last argument for New().
// New returns an Amazon S3 compatible client object. API compatibility (v2 or v4) is automatically
// determined based on the Endpoint value.
s3Client, err := minio.New("s3.amazonaws.com", &minio.Options{
Creds: credentials.NewStaticV4("YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", ""),
Secure: true,
})
if err != nil {
log.Fatalln(err)
}
obj, err := s3Client.GetObject(context.Background(), "my-bucketname", "my-objectname", minio.GetObjectOptions{})
if err != nil {
log.Fatalln(err)
}
localFile, err := os.Create("my-testfile")
if err != nil {
log.Fatalln(err)
}
defer localFile.Close()
password := []byte("myfavoritepassword") // Change as per your needs.
salt := []byte(path.Join("my-bucketname", "my-objectname")) // Change as per your needs.
_, err = sio.Decrypt(localFile, obj, sio.Config{
Key: argon2.IDKey(password, salt, 1, 64*1024, 4, 32), // generate a 256 bit long key.
})
if err != nil {
log.Fatalln(err)
}
log.Println("Successfully decrypted 'my-objectname' to local file 'my-testfile'")
}