1
// Copyright 2010 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
15
func EncryptAndGzip(dstfile, srcfile string, key, iv []byte) {
16
r, _ := os.Open(srcfile, os.O_RDONLY, 0)
18
w, _ = os.Open(dstfile, os.O_WRONLY|os.O_CREATE, 0666)
19
c, _ := aes.NewCipher(key)
20
w = block.NewOFBWriter(c, iv, w)
21
w2, _ := gzip.NewDeflater(w)
26
func DecryptAndGunzip(dstfile, srcfile string, key, iv []byte) {
27
f, _ := os.Open(srcfile, os.O_RDONLY, 0)
29
c, _ := aes.NewCipher(key)
30
r := block.NewOFBReader(c, iv, f)
31
r, _ = gzip.NewInflater(r)
32
w, _ := os.Open(dstfile, os.O_WRONLY|os.O_CREATE, 0666)
38
EncryptAndGzip("/tmp/passwd.gz", "/etc/passwd", make([]byte, 16), make([]byte, 16))
39
DecryptAndGunzip("/dev/stdout", "/tmp/passwd.gz", make([]byte, 16), make([]byte, 16))