summaryrefslogtreecommitdiff
path: root/doc/talks/io2010/encrypt.go
diff options
context:
space:
mode:
Diffstat (limited to 'doc/talks/io2010/encrypt.go')
-rw-r--r--doc/talks/io2010/encrypt.go52
1 files changed, 0 insertions, 52 deletions
diff --git a/doc/talks/io2010/encrypt.go b/doc/talks/io2010/encrypt.go
deleted file mode 100644
index 57c888c741..0000000000
--- a/doc/talks/io2010/encrypt.go
+++ /dev/null
@@ -1,52 +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.
-
-// This code differs from the slides in that it handles errors.
-
-package main
-
-import (
- "crypto/aes"
- "crypto/cipher"
- "compress/gzip"
- "io"
- "log"
- "os"
-)
-
-func EncryptAndGzip(dstfile, srcfile string, key, iv []byte) error {
- r, err := os.Open(srcfile)
- if err != nil {
- return err
- }
- var w io.WriteCloser
- w, err = os.Create(dstfile)
- if err != nil {
- return err
- }
- defer w.Close()
- w, err = gzip.NewWriter(w)
- if err != nil {
- return err
- }
- defer w.Close()
- c, err := aes.NewCipher(key)
- if err != nil {
- return err
- }
- _, err = io.Copy(cipher.StreamWriter{S: cipher.NewOFB(c, iv), W: w}, r)
- return err
-}
-
-func main() {
- err := EncryptAndGzip(
- "/tmp/passwd.gz",
- "/etc/passwd",
- make([]byte, 16),
- make([]byte, 16),
- )
- if err != nil {
- log.Fatal(err)
- }
-}