|
| 1 | +--- |
| 2 | +id: setup |
| 3 | +title: Setup |
| 4 | +hide_table_of_contents: true |
| 5 | +--- |
| 6 | + |
| 7 | +import Tabs from '@theme/Tabs'; |
| 8 | +import TabItem from '@theme/TabItem'; |
| 9 | + |
| 10 | +<Tabs groupId="programming-lang"> |
| 11 | + |
| 12 | +{' '} |
| 13 | +<TabItem value="js" label="JavaScript" default> |
| 14 | + This is how to setup the JavaScript library. |
| 15 | +</TabItem> |
| 16 | + |
| 17 | + <TabItem value="python" label="Python" default> |
| 18 | + This is how to setup the Python library. |
| 19 | + |
| 20 | +```python |
| 21 | +# Import the C2PA Python package |
| 22 | +from c2pa import * |
| 23 | + |
| 24 | +# Import standard general-purpose packages |
| 25 | +import os |
| 26 | +import io |
| 27 | +import logging |
| 28 | +import json |
| 29 | +import base64 |
| 30 | + |
| 31 | +# Import web packages used in example implementation |
| 32 | +from flask import Flask, request, abort |
| 33 | +from flask_cors import CORS |
| 34 | +from waitress import serve |
| 35 | + |
| 36 | +# Import AWS SDK package (to use KMS) |
| 37 | +import boto3 |
| 38 | +``` |
| 39 | + |
| 40 | + </TabItem> |
| 41 | + |
| 42 | + <TabItem value="node" label="Node.js"> |
| 43 | + This is how to setup the Node.js library. |
| 44 | + |
| 45 | +```js |
| 46 | +import { createC2pa } from 'c2pa-node'; |
| 47 | +import { readFile } from 'node:fs/promises'; |
| 48 | + |
| 49 | +const c2pa = createC2pa(); |
| 50 | +``` |
| 51 | + |
| 52 | + </TabItem> |
| 53 | + |
| 54 | + <TabItem value="cpp" label="C++"> |
| 55 | + |
| 56 | +```cpp |
| 57 | +#include <iostream> |
| 58 | +#include <fstream> |
| 59 | +#include <string> |
| 60 | +#include <vector> |
| 61 | +#include <stdexcept> |
| 62 | +#include <openssl/evp.h> |
| 63 | +#include <openssl/pem.h> |
| 64 | +#include <openssl/err.h> |
| 65 | +#include "c2pa.hpp" |
| 66 | +#include "test_signer.hpp" |
| 67 | +#include <nlohmann/json.hpp> |
| 68 | + |
| 69 | +// this example uses nlohmann json for parsing the manifest |
| 70 | +using json = nlohmann::json; |
| 71 | +using namespace std; |
| 72 | +namespace fs = std::filesystem; |
| 73 | +using namespace c2pa; |
| 74 | +``` |
| 75 | +
|
| 76 | + </TabItem> |
| 77 | +
|
| 78 | + <TabItem value="rust" label="Rust"> |
| 79 | + This is how to setup the Rust library. |
| 80 | +
|
| 81 | +```rust |
| 82 | +use std::{ |
| 83 | + io::{Cursor, Write}, |
| 84 | + process::{Command, Stdio}, |
| 85 | +}; |
| 86 | +
|
| 87 | +use anyhow::Result; |
| 88 | +use c2pa::{settings::load_settings_from_str, Builder, CallbackSigner, SigningAlg}; |
| 89 | +``` |
| 90 | + |
| 91 | + </TabItem> |
| 92 | + |
| 93 | +</Tabs> |
0 commit comments