Golang reads encrypted zip files

ioutil.ReadFile (absPath) if the file is an encrypted zip file, I cannot read the complete data because I want to upload the data to oss

if the zip file is not encrypted, you can read the file directly with ioutil.readfile, but for encrypted files, you cannot read the contents of zip
the files uploaded to oss are
clipboard.png

clipboard.png

I would like to ask how to deal with this situation. I am using alexmullins/zip, the open source code base compressed code

.
Jun.17,2022

there is a description of how to use it in the project introduction. And Example Encrypt zip

there is a discussion about decrypt in the project issue, and there is also a fork branch https://github.com/yeka/zip

.
Example Decrypt Zip
package main

import (
    "fmt"
    "io/ioutil"
    "log"

    "github.com/yeka/zip"
)

func main() {
    r, err := zip.OpenReader("encrypted.zip")
    if err != nil {
        log.Fatal(err)
    }
    defer r.Close()

    for _, f := range r.File {
        if f.IsEncrypted() {
            f.SetPassword("12345")
        }

        r, err := f.Open()
        if err != nil {
            log.Fatal(err)
        }

        buf, err := ioutil.ReadAll(r)
        if err != nil {
            log.Fatal(err)
        }
        defer r.Close()

        fmt.Printf("Size of %v: %v byte(s)\n", f.Name, len(buf))
    }
}

similarly, there is a SetPassword method in the original project.

Menu