io.klerch.alexa.state.utils.EncryptUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alexa-skills-kit-states-java Show documentation
Show all versions of alexa-skills-kit-states-java Show documentation
This SDK is an extension to the Alexa Skills SDK for Java. It provides a framework for managing state of POJO models in a variety of persistence stores in an Alexa skill.
package io.klerch.alexa.state.utils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class EncryptUtils {
public static String encryptSha1(final String input)
throws NoSuchAlgorithmException, UnsupportedEncodingException
{
if (input == null) return "";
final MessageDigest md = MessageDigest.getInstance("SHA1");
md.reset();
final byte[] buffer = input.getBytes("UTF-8");
md.update(buffer);
final byte[] digest = md.digest();
String hexStr = "";
for (byte aDigest : digest) {
hexStr += Integer.toString((aDigest & 0xff) + 0x100, 16).substring(1);
}
return hexStr;
}
}