# File Formats

Unless you choose to use a relational database, &kmymoney; will store all your financial information in a file ending in `.kmy`. Also, unless you use a command line option that tells it not to do so, when you launch &kmymoney;, it will open the last file it had open. However, it is important to know that there is more than one type of file &kmymoney; can use to hold your financial data.

This chapter describes the formats in which &kmymoney; stores its data in permanent form on the user's storage device. In general, &kmymoney; stores its information in form of an &XML; document. Depending on the actual format, this &XML; document will be written:

- as a plain text file encoded in UTF-8,

- as a compressed file using GZIP compression,

- as an encrypted file using GPG encryption, or

- as an anonymous plain text file encoded in UTF-8 but with all your personal data scrambled.

## Plain text file

This is the most space consuming format supported, as no compression is performed. It is not intended for normal use, and is provided to support debugging purposes and the capability to modify the file manually. If you end a filename in `.xml`, the file will be stored in this format.

Manual modification of the file is not recommended to the normal user, and should only be performed if the internal working of &kmymoney; is fully understood or if instructions from the developers tell you what to do. Don't blame the &kmymoney; developers if you screw up your data: You have been warned!

## GZIP-compressed file

This is the normal format used by &kmymoney; when you store a file with the extension `.kmy`.

If encryption has been selected, the file will be stored encrypted.

If you want to look at the contents of a GZIP compressed file, rename it to a filename ending in `.gz` (⪚, rename `myfinances.kmy` to `myfinances.kmy.gz`), then use `gunzip` to uncompress the file and look at it. You don't have to compress it before loading it into &kmymoney; the next time, because &kmymoney; can read the uncompressed data as well. Nevertheless, if you save it thereafter, it will be saved compressed again. Use the `.xml` extension to write it in uncompressed format.

## GPG-encrypted file

Using the GPG-encrypted file format is a very secure method of storing your personal finance data on your storage device. When &kmymoney; has been instructed through the settings dialog to store your data encrypted, it will cipher the data using GPG and the key you provided before actually storing it. When opening an encrypted file, you have to provide the passphrase necessary to open your keyring. The encrypted file itself will be stored in GPG's &ASCII; armored format.

When using GPG encryption, GPG also compresses the file, so no extra compression is necessary.

### GPG-Keys

If you have not done so already for mail encryption, you need to generate a key-pair in order to use the GPG encryption feature of &kmymoney;. Also, GPG must be installed on your system.

The details about how to generate a key-pair and how to take care of it are beyond the scope of this document. A Mini Howto on this subject can be found at https://www.gnupg.org/documentation/howtos.en.html.

### Setting the keys in &kmymoney;

On the encryption page of the settings dialog, there is a drop down list where you can select the key that should be used for encryption and decryption. Additionally you can find a field where you can enter the key-id of a key not in the listbox. You can use either the key-id, the email address associated with this key, or any other valid GPG key identification as the value for this field. When you enter the key-id, &kmymoney; will check its validity and display a green LED icon in the dialog if a key is found.

Make sure you have both the public and the private key for this id. If you do not own the private key for the id entered, you will not be able to open the file again.

### The &kmymoney; recover key

Also on this page of the settings dialog you have the choice of selecting supplemental encryption with the &kmymoney; recover key. This option is available to you if that key is stored in your GPG keyring. Selecting this option will allow you to recover your data even in the case you lose your own private key. This is possible because the data is not only encrypted for your own key, but also for the &kmymoney; recover key. This key is only available to selected &kmymoney; developers (at the time of writing only to the author). As of the release of &kmymoney; version 4.7, the recover key is set to expire on 3 January 2015.

Under normal circumstances, you will open/save/close your file as usual. In the abnormal case of loss of your key, you have the chance to contact one of the developers who has access to the &kmymoney; recover key and request help to recover your data. You may contact the developers via email to the &kmymoney; developer mailing list at &devlist;.

## Anonymous file

This format is not intended to be used for normal data storage. It is supported so that in case of a problem, you can supply the &kmymoney; development team with your file without disclosing any of the confidential details in your financial data. For example, it changes institution, account, payee, and category names to strings such as "I000001" and "A000001", it makes similar changes to all data such as account numbers, and it also randomly changes the amounts of transactions.

If instructed by the developers, use the Save as... menu item to store your data in anonymous format by selecting `Anonymous files` as the filter. This also changes the file extension to `.anon.xml`.

To verify that your problem still exists, reload this anonymized file and try to duplicate your problem. If the problem is still present, send the file to the developer mailing list at &devlist; for further investigation. If the problem does not show ... well, I don't want to think about this scenario right now.