Skip to content

in2group/package-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ballerina Crypto Utility Functions

This Ballerina extension is created due to some issues regarding generating HMAC with Base64 encoded keys. More can be read here:

  1. https://groups.google.com/forum/#!topic/ballerina-dev/ROqBZFWltS4

Generating HMAC using plain text key:

import ballerina/io;
import in2/crypto;

function main(string[] args) {
  string stringToSign = "test";
  string signingKey = "test";

  string result = crypto:hmac(stringToSign, signingKey, crypto:SHA256);
  io:println(result);
}

Generating HMAC using Base64 encoded key:

import ballerina/io;
import in2/crypto;

function main(string[] args) {
  string stringToSign = "test";
  string signingKey = "dGVzdA==";

  string result = crypto:hmac(stringToSign, signingKey, crypto:SHA256, keyType = crypto:BASE64);
  io:println(result);
}

About

Ballerina Crypto Utility Functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published