# PxIOPasswordSet

> Source: https://manual.pvxplus.com/pxio-library/library-functions/file-password-functions/pxiopasswordset

## Description

Sets the keyed file password

## Format

**int** **PxIOPasswordSet(PxIOFileHandle handle, const char \*password, size_t passwordSize, unsigned char permission);**

***Where:***

|  |  |
| --- | --- |
| **handle** | The handle of an open keyed file |
| **password** | A character string containing the new password |
| **passwordSize** | Length of the new password |
| **permission** | The permissions that the new password will provide. The following predefined permissions are available:<br>\|  \|  \|<br>\| --- \| --- \|<br>\| POPEN \| The password is required to open the file, read and write to it. \|<br>\| PWRITE \| The password is required to write to the file. \|<br>\| POPENDATA \| The password is required to open the file, read and write to it. Data is encrypted. \|<br>\| PWRITEDATA \| The password is required to write to the file. Data is encrypted. \| |

## Return Value

If the function succeeds, a value of PXIO_SUCCESS_STATUS is returned; otherwise, an error value is returned. More information on the nature of the error can be found by calling **[PxIOGetError](https://manual.pvxplus.com/pxio-library/library-functions/error-functions/pxiogeterror)**.

Note:  
For the function to succeed, the file must be empty, locked, and not have a password. This function provides functionality similar to the PxPlus [PASSWORD](https://manual.pvxplus.com/directives/password) directive.
