User API

EncryptionUtil

Other API in Package

Web

Internal Tunnel

Internal Web

Tunnel

Provides utility methods for obtaining message digests, HMAC and related conversions. All string conversions are made using UTF-8 encoding. In case of encryption/digest/encoding errors all methods of this class will throw workflow exception that should be handled by Pal developer

Method Summary
boolean authorizeOtp(String secretKey, int passcode)

Returns true on successful OTP authentication.

String base16toBase64(String base16)

Converts Base 16 encoded content into Base 64 encoded content

String base64toBase16(String base64)

Converts Base 64 encoded content into Base 16 encoded content

String createAESKey(int length)

Creates an AES key of the specified length and returns the Base64 encoded raw value.

String createNonce(int length)

Creates a nonce of the specified length and returns the Base64 encoded raw value.

Data createOtpAuth(String issuer, String accountName)

Returns information that can be used for an OTP Auth service. See QRUtil to create an image from the url.

int createOtpPassCode(String secretKey)

Creates an OTP pass code.

Data createPGPKeyPair(String password)

Returns a Data with two values: privateKey and publicKey. Key size is 1024. Content is Base64 encoded.

Data createRSAKeyPair(int keySize)

Returns a Data with two values: privateKey and publicKey. Content is Base64 encoded.

MailResponse decodeMessage(String message)

Decodes a raw email message.

String decrypt(String encrypted)

Decrypts the content using the cloud supplied encryption key. See encrypt(string).

String decryptAES(String publicKey, String content)

Decrypts the content using the specified AES key. Content is expected to be Base64 encoded.

String decryptRSA(String publicKey, String content)

Decrypts the content using the specified public key. Content is expected to be Base64 encoded.

String encrypt(String content)

Encrypts the content using the cloud supplied encryption key and returns it as Base64. See decrypt(string).

String encryptAES(String privateKey, String content)

Encrypts the content using the specified Base64 AES key. Result is Base64 encoded.

String encryptRSA(String privateKey, String content)

Encrypts the content using the specified private key. Result is Base64 encoded.

String fromBase16(String base16)

Decodes the Base16 content and attempts to return it as a string

String fromBase64(String base64)

Decodes the Base64 content and attempts to return it as a string

String hmacMd5(String key, String str)

Creates MD5-hashed message authentication code for a string. Result is Base16 encoded.

String hmacSha1(String key, File file, boolean isBase64Key)

Creates SHA1-hashed message authentication code for a file and returns it as Base64.

String hmacSha1(String key, String str, boolean isBase64Key)

Creates SHA1-hashed message authentication code for a string. Result is Base64 encoded.

String hmacSha256(String key, String str, boolean isBase64Key)

Creates SHA256-hashed message authentication code for a string. Result is Base64 encoded.

String md5(File file)

Calculates MD5 digest for a file and returns it as Base64.

String md5(String str)

Calculates MD5 digest for a string and returns it as Base64.

String md5Base16(File file)

Calculates MD5 digest for a file and returns it as Base16.

String md5Base16(String str)

Calculates MD5 digest for a string and returns it as Base16.

String pSha1(String requestEntropy, String serviceEntropy, int key length)

Creates P_SHA1 key with specifid length. See RFC 2246 section 5: HMAC and the pseudorandom function. Result is Base64 encoded.

String rsaSha1(String privateKey, String content)

Creates base64 encoded RSA-SHA1 for the string. Note that key should be provided as base 64 string (PEM) PKCS8 or X509.

String sha1(File file)

Calculates SHA1 digest for a file and returns it as Base64.

String sha1(String str)

Calculates SHA1 digest for a string and returns it as Base64.

String sha1Base16(File file)

Calculates SHA1 digest for a file and returns it as Base16.

String sha1Base16(String str)

Calculates SHA1 digest for a string and returns it as Base16.

String sha256(String str)

Calculates SHA256 digest for a string and returns it as Base16.

String sha256Base16(String str)

Calculates SHA256 digest for a string and returns it as Base16.

String sha512Base16(String str, int iterations)

Calculates SHA512 digest for an input over n iterations and returns it as Base16.

String toBase16(File file)

Converts file content into Base 16 encoded content.

String toBase16(String str)

Converts string bytes into Base 16 encoded content

String toBase64(File file)

Converts file content into Base 64 encoded content.

String toBase64(String str)

Converts string bytes into Base 64 encoded content

boolean verifySha1RsaSignature(File x509Cert, String base64Signature, String canonicalMessage)

Verifies the base64 encoded signature against the x509 public certificate and non encoded canonical message

boolean verifySha256RsaSignature(File x509Cert, String base64Signature, String canonicalMessage)

Verifies the base64 encoded signature against the x509 public certificate and non encoded canonical message

Method Detail


boolean authorizeOtp(String secretKey, int passcode)

Returns true on successful OTP authentication.

Parameters:

  • String   secretKey Required parameter.
  • int   passcode Required parameter.

Returns:  boolean

Since: 11-05-2019

top

String base16toBase64(String base16)

Converts Base 16 encoded content into Base 64 encoded content

Parameters:

  • String   base16  - base 16 string. Required parameter.

Returns:  String

Since: 02-07-2012

top

String base64toBase16(String base64)

Converts Base 64 encoded content into Base 16 encoded content

Parameters:

  • String   base64  - base 64 string. Required parameter.

Returns:  String

Since: 02-07-2012

top

String createAESKey(int length)

Creates an AES key of the specified length and returns the Base64 encoded raw value.

Parameters:

  • int   length  - length of key: 128, 192, 256.

Returns:  String

Since: 03-21-2013

top

String createNonce(int length)

Creates a nonce of the specified length and returns the Base64 encoded raw value.

Parameters:

  • int   length

Returns:  String

Since: 03-21-2013

top

Data createOtpAuth(String issuer, String accountName)

Returns information that can be used for an OTP Auth service. See QRUtil to create an image from the url.

Parameters:

  • String   issuer Required parameter.
  • String   accountName Required parameter.

Returns:  Data

Since: 11-05-2019

top

int createOtpPassCode(String secretKey)

Creates an OTP pass code.

Parameters:

  • String   secretKey Required parameter.

Returns:  int

Since: 02-07-2020

top

Data createPGPKeyPair(String password)

Returns a Data with two values: privateKey and publicKey. Key size is 1024. Content is Base64 encoded.

Parameters:

  • String   password Required parameter.

Returns:  Data

Since: 10-04-2013

top

Data createRSAKeyPair(int keySize)

Returns a Data with two values: privateKey and publicKey. Content is Base64 encoded.

Parameters:

  • int   keySize Maximum allowed size of parameter: 3072

Returns:  Data

Since: 11-06-2014

top

MailResponse decodeMessage(String message)

Decodes a raw email message.

Parameters:

  • String   message Required parameter.

Returns:  MailResponse

Since: 02-28-2022

top

String decrypt(String encrypted)

Decrypts the content using the cloud supplied encryption key. See encrypt(string).

Parameters:

  • String   encrypted Required parameter.

Returns:  String

Since: 11-30-2016

top

String decryptAES(String publicKey, String content)

Decrypts the content using the specified AES key. Content is expected to be Base64 encoded.

Parameters:

  • String   publicKey  - base64 encoded public key. Required parameter.
  • String   content  - Content to encrypt, base64. Required parameter.

Returns:  String

Since: 12-14-2022

top

String decryptRSA(String publicKey, String content)

Decrypts the content using the specified public key. Content is expected to be Base64 encoded.

Parameters:

  • String   publicKey  - base64 encoded public key. Required parameter.
  • String   content  - Content to encrypt, base64. Required parameter.

Returns:  String

Since: 12-14-2022

top

String encrypt(String content)

Encrypts the content using the cloud supplied encryption key and returns it as Base64. See decrypt(string).

Parameters:

  • String   content Required parameter.

Returns:  String

Since: 11-30-2016

top

String encryptAES(String privateKey, String content)

Encrypts the content using the specified Base64 AES key. Result is Base64 encoded.

Parameters:

  • String   privateKey  - base64 encoded private key. Required parameter.
  • String   content  - Content to encrypt. Required parameter.

Returns:  String

Since: 12-14-2022

top

String encryptRSA(String privateKey, String content)

Encrypts the content using the specified private key. Result is Base64 encoded.

Parameters:

  • String   privateKey  - base64 encoded private key. Required parameter.
  • String   content  - Content to encrypt. Required parameter.

Returns:  String

Since: 12-14-2022

top

String fromBase16(String base16)

Decodes the Base16 content and attempts to return it as a string

Parameters:

  • String   base16  - base 16 string. Required parameter.

Returns:  String

Since: 01-09-2019

top

String fromBase64(String base64)

Decodes the Base64 content and attempts to return it as a string

Parameters:

  • String   base64  - base 64 string. Required parameter.

Returns:  String

Since: 01-09-2019

top

String hmacMd5(String key, String str)

Creates MD5-hashed message authentication code for a string. Result is Base16 encoded.

Parameters:

  • String   key  - base16 encoded key. Required parameter.
  • String   str  - string with content. Required parameter.

Returns:  String

Since: 08-23-2018

top

String hmacSha1(String key, File file, boolean isBase64Key)

Creates SHA1-hashed message authentication code for a file and returns it as Base64.

Parameters:

  • String   key  - key. Required parameter.
  • File   file  - file with content. Required parameter.
  • boolean   isBase64Key  - true if key is base64. Required parameter.

Returns:  String

Since: 12-02-2015

top

String hmacSha1(String key, String str, boolean isBase64Key)

Creates SHA1-hashed message authentication code for a string. Result is Base64 encoded.

Parameters:

  • String   key  - key. Required parameter.
  • String   str  - string with content. Required parameter.
  • boolean   isBase64Key  - true if key is base64. Required parameter.

Returns:  String

Since: 12-02-2015

top

String hmacSha256(String key, String str, boolean isBase64Key)

Creates SHA256-hashed message authentication code for a string. Result is Base64 encoded.

Parameters:

  • String   key  - key. Required parameter.
  • String   str  - string with content. Required parameter.
  • boolean   isBase64Key  - true if key is base64. Required parameter.

Returns:  String

Since: 11-08-2016

top

String md5(File file)

Calculates MD5 digest for a file and returns it as Base64.

Parameters:

  • File   file  - file to calculate hash for. Required parameter.

Returns:  String

Since: 02-07-2012

top

String md5(String str)

Calculates MD5 digest for a string and returns it as Base64.

Parameters:

  • String   str  - string to calculate hash for. Required parameter.

Returns:  String

Since: 02-07-2012

top

String md5Base16(File file)

Calculates MD5 digest for a file and returns it as Base16.

Parameters:

  • File   file  - file to calculate hash for. Required parameter.

Returns:  String

Since: 09-14-2023

top

String md5Base16(String str)

Calculates MD5 digest for a string and returns it as Base16.

Parameters:

  • String   str  - string to calculate hash for. Required parameter.

Returns:  String

Since: 09-14-2023

top

String pSha1(String requestEntropy, String serviceEntropy, int key length)

Creates P_SHA1 key with specifid length. See RFC 2246 section 5: HMAC and the pseudorandom function. Result is Base64 encoded.

Parameters:

  • String   requestEntropy  - base64 encoded request content. Required parameter.
  • String   serviceEntropy  - base64 encoded service content. Required parameter.
  • int   key length  - length of key. 32 for AES256, etc. Required parameter.

Returns:  String

Since: 03-21-2013

top

String rsaSha1(String privateKey, String content)

Creates base64 encoded RSA-SHA1 for the string. Note that key should be provided as base 64 string (PEM) PKCS8 or X509.

Parameters:

  • String   privateKey  - base64 encoded private key. Required parameter.
  • String   content  - Content to encrypt. Required parameter.

Returns:  String

Since: 11-03-2014

top

String sha1(File file)

Calculates SHA1 digest for a file and returns it as Base64.

Parameters:

  • File   file  - file to calculate hash for. Required parameter.

Returns:  String

Since: 02-07-2012

top

String sha1(String str)

Calculates SHA1 digest for a string and returns it as Base64.

Parameters:

  • String   str  - string to calculate hash for. Required parameter.

Returns:  String

Since: 02-07-2012

top

String sha1Base16(File file)

Calculates SHA1 digest for a file and returns it as Base16.

Parameters:

  • File   file  - file to calculate hash for. Required parameter.

Returns:  String

Since: 09-14-2023

top

String sha1Base16(String str)

Calculates SHA1 digest for a string and returns it as Base16.

Parameters:

  • String   str  - string to calculate hash for. Required parameter.

Returns:  String

Since: 09-14-2023

top

String sha256(String str)

Calculates SHA256 digest for a string and returns it as Base16.

Parameters:

  • String   str  - string to calculate hash for. Required parameter.

Returns:  String

Since: 11-08-2016

top

String sha256Base16(String str)

Calculates SHA256 digest for a string and returns it as Base16.

Parameters:

  • String   str  - string to calculate hash for. Required parameter.

Returns:  String

Since: 09-14-2023

top

String sha512Base16(String str, int iterations)

Calculates SHA512 digest for an input over n iterations and returns it as Base16.

Parameters:

  • String   str  - string to calculate hash for. Required parameter.
  • int   iterations Maximum allowed size of parameter: 50

Returns:  String

Since: 08-04-2017

top

String toBase16(File file)

Converts file content into Base 16 encoded content.

Parameters:

  • File   file  - file to encode. Required parameter.

Returns:  String

Since: 02-07-2012

top

String toBase16(String str)

Converts string bytes into Base 16 encoded content

Parameters:

  • String   str  - string to encode. Required parameter.

Returns:  String

Since: 02-07-2012

top

String toBase64(File file)

Converts file content into Base 64 encoded content.

Parameters:

  • File   file  - file to encode. Required parameter.

Returns:  String

Since: 02-07-2012

top

String toBase64(String str)

Converts string bytes into Base 64 encoded content

Parameters:

  • String   str  - string to encode. Required parameter.

Returns:  String

Since: 02-07-2012

top

boolean verifySha1RsaSignature(File x509Cert, String base64Signature, String canonicalMessage)

Verifies the base64 encoded signature against the x509 public certificate and non encoded canonical message

Parameters:

  • File   x509Cert Required parameter.
  • String   base64Signature Required parameter.
  • String   canonicalMessage Required parameter.

Returns:  boolean

Since: 11-13-2018

top

boolean verifySha256RsaSignature(File x509Cert, String base64Signature, String canonicalMessage)

Verifies the base64 encoded signature against the x509 public certificate and non encoded canonical message

Parameters:

  • File   x509Cert Required parameter.
  • String   base64Signature Required parameter.
  • String   canonicalMessage Required parameter.

Returns:  boolean

Since: 06-03-2021

top
Copyright © 2006 - 2024, ContractPal, Inc. All rights reserved. API Date: Dec 03, 2024 10:24 AM