English
  1. Home
  2. Security
  3. Lock

Lock

Set password for PDF document

copy
Something went wrong, try again
copy
            
                    
        
Body parameter
Parameter VALUE DESCRIPTION

lockRequest

Required

copy
LockRequest LockRequest Insurance
LockRequest
Parameter VALUE DESCRIPTION

PdfBase64File

Required

close-icon
string Base64 encoded PDF document to process

UserPasswordBase64

Required

string Base64 encrypted user password

OwnerPasswordBase64

Optional

string Base64 encrypted owner password
copy Copy to clipboard
        
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.documentize.cloud/security/lock"
  method := "POST"

  payload := strings.NewReader(`{
      "UserPasswordBase64": "Base64 encoded string...",
      "OwnerPasswordBase64": "Base64 encoded string...",
      "PdfBase64File": "Base64 encoded file...",
    }`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
                   
         
            
File file = new File("path/to/file/fileName.pdf");
byte[] encoded = Base64.encodeBase64(FileUtils.readFileToByteArray(file));
String base64EncodedFile = new String(encoded, StandardCharsets.US_ASCII);

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, 
    "{" +
      "\"UserPasswordBase64\": \"Base64 encoded string...\"," +
      "\"OwnerPasswordBase64\": \"Base64 encoded string...\"," +
      "\"PdfBase64File\": \"" + base64EncodedFile + "\"," +
    "}");

Request request = new Request.Builder()
  .url("https://api.documentize.cloud/security/lock")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .build();

Response response = client.newCall(request).execute();
                   
        
            
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.documentize.cloud/security/lock',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
      "UserPasswordBase64": "Base64 encoded string...",
      "OwnerPasswordBase64": "Base64 encoded string...",
      "PdfBase64File": "Base64 encoded file...",
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
                   
        
            
import requests
import json

url = "https://api.documentize.cloud/security/lock"

json_data = json.dumps({
      "UserPasswordBase64": "Base64 encoded string...",
      "OwnerPasswordBase64": "Base64 encoded string...",
      "PdfBase64File": "Base64 encoded file...",
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=json_data)

print(response.text)
                   
        
            
curl --location --request POST 'https://api.documentize.cloud/security/lock' \
--header 'Content-Type: application/json' \
--data-raw '{
      "UserPasswordBase64": "Base64 encoded string...",
      "OwnerPasswordBase64": "Base64 encoded string...",
      "PdfBase64File": "Base64 encoded file...",
}'
                   
        
            
require "uri"
require "json"
require "net/http"

url = URI("https://api.documentize.cloud/security/lock")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = JSON.dump({
      "UserPasswordBase64": "Base64 encoded string...",
      "OwnerPasswordBase64": "Base64 encoded string...",
      "PdfBase64File": "Base64 encoded file...",
})

response = https.request(request)
puts response.read_body

                   
        
            
var client = new RestClient("https://api.documentize.cloud/security/lock");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
var body = "{" + 
      "\"UserPasswordBase64\": \"Base64 encoded string...\"," +
      "\"OwnerPasswordBase64\": \"Base64 encoded string...\"," +
      "\"PdfBase64File\": \"" + base64EncodedFile + "\"," +
"}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
                       
            
Overview

About Lock Method

This page offers comprehensive instructions on how to effectively utilize our cloud API for password protecting your PDF files in multiple programming languages, such as Go, Java, PHP, Python, Curl, Ruby, and C#. Our "Lock" Security API method enables you to set two types of passwords - user password and owner password, ensuring enhanced security for your PDF files.


Programming languages the API is compatible with

Our API uses the REST protocol, making it compatible with popular programming languages such as Go, Java, PHP, Python, Curl, Ruby, and C# etc.

Easy to use

Our API Reference and Guide are designed to be user-friendly and easy to follow, providing all the necessary information for a quick start. Furthermore, our API Libraries are accompanied by their own documentation, making integration into your application seamless. With our comprehensive resources, you can efficiently utilize our API to meet your specific requirements.

Secure

At our company, we place a high priority on your security and privacy. To protect your private data, we never store it in our environment and offer isolated options. We understand the importance of keeping your information safe and take all necessary measures to ensure that it remains secure.
Lock PDF File
clock
Add a File
To ensure seamless and precise protection of your PDF file using the "Lock" method (Security API), it is crucial to confirm that the file you are working with matches the one specified in the method. This ensures that the appropriate password setting method (user or owner password) is used to effectively safeguard your file during processing.
arrow
clock
Run the Code
To run the code, copy and paste it into a file and execute it from the same directory where you added the necessary files. For further details, refer to our language-specific guides on how to get started.
arrow
clock
View the Result
To access the results of the "Lock" method (Security API), you can simply open the file received as the output, which will be located in your project folder. If you opt to use the "Lock" method online to protect your PDF file by setting user or owner password, the process will automatically generate a password-protected PDF file, which will be promptly downloaded for your convenience.
clock
How long does it takes to protect PDF file by setting password using "Lock" method (Security API)?
Our Security API, particularly the "Lock" method, is optimized for fast and efficient file processing. With our service, you can expect rapid results, often delivered within seconds, allowing you to swiftly protect your PDF file by setting a password and streamline your workflow for enhanced productivity.
clock
Is it safe to use "Lock" method (Security API)?
The safety and privacy of your data are our top priorities. As a company, we have implemented robust measures to ensure the security of your information. We do not store any files submitted for processing, and they are solely processed to provide you with the desired results. Your security and confidentiality are of utmost importance to us, and we take every precaution to safeguard your data throughout the entire process.
clock
What output can I expect from the "Lock" method (Security API)?
With our "Lock" method (Security API), you can effectively protect your PDF document by setting passwords. Our API supports two types of passwords: user password and owner password. This enables you to secure your file to the fullest extent and restrict access only to a select group of individuals, ensuring maximum security and privacy for your PDF document.
clock
How does method “Lock” (Security API) works?
With our "Lock" method (Security API), you can easily set a password to protect your PDF file. Our user-friendly and seamless process allows you to effortlessly upload your file, click the "POST" button, and quickly receive the results, typically within seconds. The output will be password-protected PDF file. To integrate this method into your project, simply copy and use the provided code examples in the programming language of your choice for smooth and efficient integration. Our API is designed to work seamlessly with popular programming languages like Go, Java, PHP, Python, Curl, Ruby, C#, and more, utilizing the REST protocol for smooth integration and compatibility.
FAQ

Frequently Asked Questions

We encourage you to review our Frequently Asked Questions (FAQ) section for answers to common inquiries. If you do not find the information you need, our dedicated support service is readily available to assist you with any additional questions or concerns. Don't hesitate to reach out for further assistance.