# \encrypted_store

A utility class for caching encrypted information.

This class automatically calculates an encryption key with session specific entropy. However the encryption key can be overridden.

## Summary

Methods
Properties
Constants
get_timeout()
set_timeout()
set_key()
put()
put_special()
get()
get_special()
erase()
cleanup()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

File
  lib/class.encrypted_store.php
Package
  \CGExtensions
Class hierarchy
  \encrypted_store
See also

## Tags

todo |

## Methods

### get_timeout()

    get_timeout() : int

Get the data expiry time in seconds

#### Returns

int

#

static

## Tags

todo |

### set_timeout()

    set_timeout(int $num)

Set the data expiry time in seconds.

Since this is encrypted data, it's lifetime is expected to be very short. A maximum of 5 minutes (300 seconds)

#### Parameters

int | $num | Expiry timeout in seconds.

#

static

## Tags

todo |

### set_key()

    set_key(string $str)

Override the encryption key.

It is important to set this key with a long enough value and with enough entropy to be random for different purposes. i.e: if storing user specific data for a short time it may be appropriate to use the session id as part of the encryption key.

#### Parameters

string | $str |

#

static

## Tags

todo |

### put()

    put(string $data, string $key1, string $key2, string $key3)

Store encrypted data

#### Parameters

string | $data | The data to store
string | $key1 | The first key in the encrypted set. Up to three keys can be used
string | $key2 | The optional second key in the encrypted set
string | $key3 | The optional third key in the encrypted set

#

static

## Tags

todo |

### put_special()

    put_special(string $data, string $specialkey, string $key1, string $key2, string $key3)

A convenience method to store data with a special encryption key.

#### Parameters

string | $data | The data to store
string | $specialkey | The override encryption key.
string | $key1 | The first key in the encrypted set. Up to three keys can be used
string | $key2 | The optional second key in the encrypted set
string | $key3 | The optional third key in the encrypted set

#

static

## Tags

todo |

### get()

    get(string $key1, string $key2, string $key3) : \string.

unencrypt and return stored data

#### Parameters

string | $key1 | The first key in the encrypted set. Up to three keys can be used
string | $key2 | The optional second key in the encrypted set
string | $key3 | The optional third key in the encrypted set

#### Returns

\string.

#

static

## Tags

todo |

### get_special()

    get_special(string $specialkey, string $key1, string $key2, string $key3) : \string.

unencrypt and return stored data using a special encryption key

#### Parameters

string | $specialkey | The override encryption key.
string | $key1 | The first key in the encrypted set. Up to three keys can be used
string | $key2 | The optional second key in the encrypted set
string | $key3 | The optional third key in the encrypted set

#### Returns

\string.

#

static

## Tags

todo |

### erase()

    erase(string $key1, string $key2, string $key3)

Erase encrypted data from the datastore

#### Parameters

string | $key1 | The first key in the encrypted set. Up to three keys can be used
string | $key2 | The optional second key in the encrypted set
string | $key3 | The optional third key in the encrypted set

#

static

## Tags

todo |

### cleanup()

    cleanup()

Clean all expired data.

#

static

## Tags

todo |

### class.encrypted_store.php