From 80f18fc933cf3f3e829c5455a1023d69f7b86e52 Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Tue, 13 Sep 2011 13:11:55 +0200 Subject: Imported Upstream version 60 --- doc/talks/io2010/decrypt.go | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 doc/talks/io2010/decrypt.go (limited to 'doc/talks/io2010/decrypt.go') diff --git a/doc/talks/io2010/decrypt.go b/doc/talks/io2010/decrypt.go deleted file mode 100644 index 3292c30b2..000000000 --- a/doc/talks/io2010/decrypt.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "crypto/aes" - "crypto/block" - "compress/gzip" - "io" - "os" -) - -func EncryptAndGzip(dstfile, srcfile string, key, iv []byte) { - r, _ := os.Open(srcfile, os.O_RDONLY, 0) - var w io.Writer - w, _ = os.Open(dstfile, os.O_WRONLY|os.O_CREATE, 0666) - c, _ := aes.NewCipher(key) - w = block.NewOFBWriter(c, iv, w) - w2, _ := gzip.NewDeflater(w) - io.Copy(w2, r) - w2.Close() -} - -func DecryptAndGunzip(dstfile, srcfile string, key, iv []byte) { - f, _ := os.Open(srcfile, os.O_RDONLY, 0) - defer f.Close() - c, _ := aes.NewCipher(key) - r := block.NewOFBReader(c, iv, f) - r, _ = gzip.NewInflater(r) - w, _ := os.Open(dstfile, os.O_WRONLY|os.O_CREATE, 0666) - defer w.Close() - io.Copy(w, r) -} - -func main() { - EncryptAndGzip("/tmp/passwd.gz", "/etc/passwd", make([]byte, 16), make([]byte, 16)) - DecryptAndGunzip("/dev/stdout", "/tmp/passwd.gz", make([]byte, 16), make([]byte, 16)) -} -- cgit v1.2.3