code: func PublicKeyToEncryptedPEM(publicKey interface{}, pwd []byte) ([]byte, error) {
  	if publicKey == nil {
  		return nil, errors.New("Invalid public key. It must be different from nil.")
  	}
  	if len(pwd) == 0 {
  		return nil, errors.New("Invalid password. It must be different from nil.")
  	}
  
  	switch k := publicKey.(type) {
  	case *ecdsa.PublicKey:
  		if k == nil {
  			return nil, errors.New("Invalid ecdsa public key. It must be different from nil.")
  		}
  		raw, err := x509.MarshalPKIXPublicKey(k)
  		if err != nil {
  			return nil, err
  		}
  
  		block, err := x509.EncryptPEMBlock(
  			rand.Reader,
  			"PUBLIC KEY",
  			raw,
  			pwd,
  			x509.PEMCipherAES256)
  
  		if err != nil {
  			return nil, err
  		}
  
  		return pem.EncodeToMemory(block), nil
  
  	default:
  		return nil, errors.New("Invalid key type. It must be *ecdsa.PublicKey")
  	}
  }
docs: // PublicKeyToEncryptedPEM converts a public key to encrypted pem