Skip to content

Instantly share code, notes, and snippets.

@kwmt
Created July 20, 2013 01:52
Show Gist options
  • Save kwmt/6043517 to your computer and use it in GitHub Desktop.
Save kwmt/6043517 to your computer and use it in GitHub Desktop.
How to use compress/bzip2
//python challenge 8
//問題 http://www.pythonchallenge.com/pc/def/integrity.html
package main
import (
"compress/bzip2"
"fmt"
"io"
"os"
"strings"
)
func main() {
un := "BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084"
pw := "BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08"
printdecomp(un)
printdecomp(pw)
}
func printdecomp(s string) {
sr := strings.NewReader(s) // stinrg → strings.Reader (io.Reader)
ir := bzip2.NewReader(sr) // io.Reader→ decompresses bzip2 data io.Reader
_, err := io.Copy(os.Stdout, ir) // 標準出力
if err != nil {
fmt.Println(err)
}
fmt.Println() //改行
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment