Aws kms encrypt/decrypt example java

What is KMS ?

KMS is a ‘Key Management System’, help you to create and manage cryptographic keys. It helps in control use of ‘cryptographic keys’ across a wide range of AWS services and in your applications.

Application can be in C#, Go, Java, Node, PHP, Python, and Ruby or you can say KMS supported languages. SDK related to all is available on AWS site.

When to Use KMS ?

KMS is to store encryption/decryption DATA keys. Further, use data keys to encrypt and decrypt, with AWS Encryption SDK.

Code Time


implementation platform('')
implementation ''

 implementation platform('com.amazonaws:aws-java-sdk-bom:1.12.116')
 implementation 'com.amazonaws:aws-java-sdk-kms'

Java Code

public AWSKMS kmsClient() {
    String apiKey = <from aws console>
    String apiSecrete = <from aws console>
    AWSCredentialsProvider credentialsProvider = null;

    AWSCredentials credentials = new BasicAWSCredentials(apiKey, apiSecrete);
    credentialsProvider = new AWSStaticCredentialsProvider(credentials);

    return AWSKMSClientBuilder.standard()
            .withRegion(Regions.<aws region from your console>)
private final AWSKMS kmsClient;

public String encrypt(String input) throws Exception {
    String kmskey = <KMS key arn from aws console>
    ByteBuffer plaintext = ByteBuffer.wrap(input.getBytes(StandardCharsets.UTF_8));
    EncryptRequest req = new EncryptRequest().withKeyId(kmskey).withPlaintext(plaintext);
    ByteBuffer ciphertext = kmsClient.encrypt(req).getCiphertextBlob();
    String data = Base64.getUrlEncoder().encodeToString(ciphertext.array());
    return data;
public String decrypt(String input) throws Exception {
    String kmskey = <from console>
    byte cipherBytes[] = Base64.getUrlDecoder().decode(input);
    ByteBuffer cipherBuffer = ByteBuffer.wrap(cipherBytes);
    DecryptRequest req = new DecryptRequest().withKeyId(kmskey).withCiphertextBlob(cipherBuffer);
    DecryptResult resp = kmsClient.decrypt(req);
    return new String(resp.getPlaintext().array(), Charset.forName("UTF-8"));


Amazon affiliated marketing by WordPress Website with SEO

Learn creating Domain, Hosting  website and creating E-Commerce Store using WordPress. Explore the idea with SEO and Rank your website to earn Passive Income by Building an Amazon Affiliate website with lot’s of light weight plugging’s  and oceanWS Theme, without any Coding.

Learn Domain Selection, KeyWord Selection and creating Do-Follow Backlinks to increase Rank and Domain authority of your website.

By taking this course not only will you be able to build a complete Amazon Affiliated e-commerce website, but you’ll also learn how to populate it with millions of top rated Amazon products and Rank high in Google. You’ll learn to create sales and earn a generous commission on each sale.

Let’s go through a quick overview of exactly what you will learn in this course:

  • Section 1:
    Includes an introduction to the Course with finding a best Deal for Domain and Hosting server purchase.
  • Section 2:
    Introduction to WordPress site maker and admin view. Installing SSL cert and oceanWp theme for your site.With creating amazon store and first post.
  • Section 3
    Very Important, what we should avoid to do.
  • Section 4:
    In this section we will learn What to build for a Good Website i.e. keyword Selection and their importance. Adding Rank Math SEO plugin and Google site plugin for analytics and Google search results.
  • Section 5:What are backlinks, what is difference between DoFollow and NpFollow links and above all what are techniques to get DoFollow links.
  • Section 6:
    It’s a site maintenance section, where we check where we need to go for site updates, backup and how to connect our site deployment server via a SFTP.


A backlink is a link created when one website links to another. Backlinks are also called “inbound links” or “incoming links.” Backlinks are important to SEO and as their number increases it boost confidence in site content results increase in site Google Rank.

Backlinks are of two type Dofollow and Nofollow.


<a href=””>Link Text</a>

Dofollow links are the type of backlink that we want. Just keep in mind that those coming from respected sites hold the most value. This kind of backlink can help improve your search engine rankings.


<a href=”” rel=”nofollow”>Link Text</a>

Nofollow tag tells search engines to ignore a link. They don’t pass any value from one site to another. So, typically they aren’t helpful in improving your search rank or visibility.

Techniques to create Backlinks

  • Update Udemy profile with website link.
  • Update Twitter profile with website link.
  • Create account on amazon community and add website link in your profile.
  • Create blogs on wordpress, wix or wordpress(Free).
  • Create facebook page and add your posts.


What Is SEO?

SEO stands for search engine optimization. SEO is the technique of taking steps to help a website or piece of content rank high in search engine like Bing, Google etc.

What are search statistics of different Search Engines ?

Search Engines% used in 2020
Yandexwhat all remaining

Regional Distribution of Google Search Traffic

Area% search traffic

% click on Google search results by position

CLR – click-through rate

Page Position% click

Ways to Improve your Site’s Ranking

  • Create and Publish relevant and authoritative Content.
  • Content must be updated regularly.
  • Use alt tags.
  • Attract links from other websites, blogs, online forums and comments.
  • Create Metadata(Title, Description and keyword) rich website.