code: func Encrypt(password string, plaintext []byte) (encrypted []byte, err error) {
  	// Derive key material from password and salt.
  	salt := make([]byte, 8)
  	_, err = io.ReadFull(rand.Reader, salt)
  	if err != nil {
  		return nil, err
  	}
  	aesKey, hmacKey, keyHash := deriveKey(password, salt)
  
  	// Pad.
  	n := aes.BlockSize - len(plaintext)%aes.BlockSize
  	dec := make([]byte, len(plaintext)+n)
  	copy(dec, plaintext)
  	for i := len(plaintext); i < len(dec); i++ {
  		dec[i] = byte(n)
  	}
  
  	// Encrypt.
  	iv := make([]byte, aes.BlockSize)
  	_, err = io.ReadFull(rand.Reader, iv)
  	if err != nil {
  		return nil, err
  	}
  	aesBlock, err := aes.NewCipher(aesKey)
  	if err != nil {
  		// Cannot happen - key is right size.
  		panic("aes: " + err.Error())
  	}
  	m := cipher.NewCBCEncrypter(aesBlock, iv)
  	enc := make([]byte, len(dec))
  	m.CryptBlocks(enc, dec)
  
  	// Construct packet.
  	var pkt []byte
  	pkt = append(pkt, version)
  	pkt = append(pkt, salt...)
  	pkt = append(pkt, keyHash...)
  	pkt = append(pkt, iv...)
  	pkt = append(pkt, enc...)
  
  	// Sign.
  	h := hmac.New(sha1.New, hmacKey)
  	h.Write(pkt)
  	pkt = append(pkt, h.Sum(nil)...)
  
  	return pkt, nil
  }
docs: // Encrypt encrypts the plaintext into an encrypted packet
  // using the given password. The password is required for
  // decryption.