# Creating a timestamp
# Calculate SHA-256
To create a timestamp, you must first calculate the SHA-256
hash of your record. There are standard libraries for all programming languages:
Java
public String getSHA256(byte[] input) {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] encodedhash = digest.digest(input);
return bytesToHex(encodedhash);
}
private static String bytesToHex(byte[] hash) {
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < hash.length; i++) {
String hex = Integer.toHexString(0xff & hash[i]);
if(hex.length() == 1) hexString.append('0');
hexString.append(hex);
}
return hexString.toString();
}
C#
static string ComputeSha256Hash(string rawData)
{
// Create a SHA256
using (SHA256 sha256Hash = SHA256.Create())
{
// ComputeHash - returns byte array
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));
// Convert byte array to a string
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
return builder.ToString();
}
}
Python
import hashlib
hashlib.sha256("test").hexdigest()
# Submit your hash
# Request
POST /v4/timestamp/create
curl -X POST "http://api.originstamp.com/v4/timestamp/create"\
-H "Authorization: YOUR_API_KEY"\
-H "Content-Type: application/json"\
-d 'YOUR_PAYLOAD'
# Payload
{
"comment": "test",
"hash": "2c5d36be542f8f0e7345d77753a5d7ea61a443ba6a9a86bb060332ad56dba38e",
"notifications": [
{
"currency": 0,
"notification_type": 0,
"target": "mail@notification.de"
},
{
"currency": 0,
"notification_type": 1,
"target": "https://webhook-notification.url"
}
],
"url": "string"
}
# comment
(optional)
You can add a short comment (max. 256 characters) which can be used for indexing and searching (privacy-preserving).
Example
test
# hash
(required)
Hash in HEX representation. We suggest to use SHA-256
. This hash will be aggregated and included into the blockchain.
Example
2c5d36be542f8f0e7345d77753a5d7ea61a443ba6a9a86bb060332ad56dba38e
# notifications
(optional)
Add a list of notifications to your submission. Our system will notify each specified target with the corresponding timestamp information when the status is verified in a Blockchain.
Example for a mail notification on Bitcoin
[{
"currency": 0,
"notification_type": 0,
"target": "no-reply@originstamp.com"
}]
Example for a URL webhook notification on Ethereum
[{
"currency": 1,
"notification_type": 1,
"target": "https://no-reply.originstamp.com/callback"
}]
# currency
0
: Bitcoin1
: Ethereum100
: Südkurier
# notification_type
0
: Mail1
: Webhook
# target
Mail address or URL to which the notification should be sent.
# url
(optional)
This optional parameter which can be used for a preprint URL.
You can generate a UUID-4
beforehand and include it into your document. When submitting
your file, the URL is part of the hash, which finally means the link to the timestamp is
part of the timestamp itself.
# Response
{
"data": {
"comment": "string",
"created": false,
"date_created": 0,
"hash_string": "string",
"timestamps": [
{
"seed_id": "string",
"currency_id": 0,
"private_key": "string",
"submit_status": 0,
"timestamp": 0,
"transaction": "string"
}
]
},
"error_code": 0,
"error_message": "string"
}
This response object is identical in structure to the timestamp status response. Explanations of the individual fields can be found below.
# created
If true
, this was the first time the hash was submitted to OriginStamp.