Skip to content

Commit 3f966a7

Browse files
authored
adding the KMS samples for creating keys, keyrings, encrypt and decrypt (GoogleCloudPlatform#302)
1 parent 8db280c commit 3f966a7

File tree

13 files changed

+1222
-1
lines changed

13 files changed

+1222
-1
lines changed

kms/api/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Google Cloud KMS API Samples
2+
3+
## Description
4+
5+
These samples show how to use the [Google Cloud KMS API]
6+
(https://cloud.google.com/kms/).
7+
8+
## Build and Run
9+
1. **Enable APIs** - [Enable the KMS API](https://console.cloud.google.com/flows/enableapi?apiid=cloudkms.googleapis.com)
10+
and create a new project or select an existing project.
11+
2. **Download The Credentials** - Click "Go to credentials" after enabling the APIs. Click "Create Credentials"
12+
and select "API key". Copy the API key.
13+
3. **Clone the repo** and cd into this directory
14+
```
15+
$ git clone https://github.com/GoogleCloudPlatform/php-docs-samples
16+
$ cd php-docs-samples/kms/api
17+
```
18+
4. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md).
19+
Run `php composer.phar install` (if composer is installed locally) or `composer install`
20+
(if composer is installed globally).
21+
5. **Run**:
22+
```sh
23+
$ php create_keyring.php
24+
Usage: create_keyring.php [project_id] [name]
25+
$ php create_cryptokey.php
26+
Usage: create_cryptokey.php [project_id] [keyring] [name]
27+
$ php encrypt.php
28+
Usage: encrypt.php [key_name] [infile] [outfile]
29+
$ php decrypt.php
30+
Usage: decrypt.php [key_name] [infile] [outfile]
31+
```
32+
33+
## Contributing changes
34+
35+
* See [CONTRIBUTING.md](../../CONTRIBUTING.md)
36+
37+
## Licensing
38+
39+
* See [LICENSE](../../LICENSE)

kms/api/composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"require": {
3+
"google/apiclient": "^2.1"
4+
},
5+
"require-dev": {
6+
"symfony/process": "^3.2"
7+
}
8+
}

0 commit comments

Comments
 (0)