All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.klerch.alexa.state.utils.EncryptUtils Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.1.0
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy