Example usage for org.apache.commons.codec.digest DigestUtils sha1Hex

List of usage examples for org.apache.commons.codec.digest DigestUtils sha1Hex

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest DigestUtils sha1Hex.

Prototype

public static String sha1Hex(String data) 

Source Link

Usage

From source file:controleur.moncompte.CmdCreationClient.java

@Override
public String execute(HttpServletRequest request, HttpServletResponse response) {

    Utilisateur utilisateur = new Utilisateur();
    utilisateur.setLogin(request.getParameter("pseudo"));
    utilisateur.setEmail(request.getParameter("mail"));
    utilisateur.setPassword(DigestUtils.sha1Hex(request.getParameter("password")));

    REST_Utilisateur ru = new REST_Utilisateur();
    ru.create_JSON(utilisateur);//from  w ww  .  ja v a  2  s .  com
    return "WEB-INF/accueil.jsp";
}

From source file:fileserver.Utils.java

/**
 * Compute unique identificator uploaded file
 * @param fi - FileItem/*from   w w  w  . ja va  2s  .co  m*/
 * @return SHA1 Hex string
 */
public static String calcID(FileItem fi) {
    try {
        return DigestUtils.sha1Hex(fi.getInputStream());
    } catch (IOException ex) {
        logger.error("calcId", ex);
        return "";
    }
}

From source file:com.webarch.common.lang.Digest.java

/**
 * sha1??????UTF-8//from w w  w .j a v  a 2 s .c om
 *
 * @param sources ?
 * @return ?
 */
public static String signatureString(final String... sources) {
    String source;
    if (sources.length == 1) {
        source = sources[0];
    } else {
        source = generateSourceString(sources);
    }
    return DigestUtils.sha1Hex(source);
}

From source file:controleur.moncompte.CmdEssaiConnexion.java

@Override
public String execute(HttpServletRequest request, HttpServletResponse response) {

    REST_Utilisateur ru = new REST_Utilisateur();
    Boolean connecte = Boolean.valueOf(ru.verifier(String.class, request.getParameter("identifiant"),
            DigestUtils.sha1Hex(request.getParameter("password"))));
    if (connecte) {
        Connexion connexion = new Connexion();
        connexion.setConnexion(true);//from w  ww  .j  a  v a  2s  .com
        Utilisateur utilisateur;
        utilisateur = ru.findByLogin_JSON(Utilisateur.class, request.getParameter("identifiant"));
        HttpSession httpSession = request.getSession(false);
        httpSession.setAttribute("connexion", connexion);
        httpSession.setAttribute("utilisateur", utilisateur);
        return "WEB-INF/accueil.jsp";
    } else {
        String erreur = "Erreur identification";
        request.setAttribute("erreur", erreur);
        request.setAttribute("identifiant", request.getParameter("identifiant"));
        request.setAttribute("password", request.getParameter("password"));
        return "WEB-INF/connexion.jsp";
    }
}

From source file:com.wallellen.wechat.common.util.crypto.SHA1.java

/**
 * arr??sha1 digest/*from  w ww.  jav a2 s . c o  m*/
 *
 * @param arr
 * @return
 */
public static String gen(String... arr) throws NoSuchAlgorithmException {
    Arrays.sort(arr);
    StringBuilder sb = new StringBuilder();
    for (String a : arr) {
        sb.append(a);
    }
    return DigestUtils.sha1Hex(sb.toString());
}

From source file:io.fabric8.elasticsearch.plugin.acl.BaseRolesSyncStrategyTest.java

@Test
public void testFormatUserNameRoleFromEmail() {
    assertEquals("gen_user_" + DigestUtils.sha1Hex("user@email.com"), formatUserRoleName("user@email.com"));
}

From source file:com.google.gwt.site.uploader.HashCalculatorSha1Impl.java

@Override
public String calculateHash(File file) throws IOException {
    FileInputStream fis = null;//w  w  w .  j  a v  a  2s . co  m
    try {
        fis = new FileInputStream(file);
        return DigestUtils.sha1Hex(fis);
    } finally {
        IOUtils.closeQuietly(fis);
    }
}

From source file:br.com.gestaoigrejas.sgi.service.CollaboratorService.java

public void create(CollaboratorDTO collaboratorDTO) {
    Collaborator collaborator = CollaboratorDTO.fromDTO(collaboratorDTO);
    collaborator.getMember().setCollaborator(collaborator);

    collaborator.getLogin().setPassword(DigestUtils.sha1Hex(collaborator.getLogin().getPassword()));
    collaborator.getLogin().setStatus(Status.ACTIVE);
    collaborator.getLogin().setRegistration(new Date());
    collaborator.getLogin().setLastUpdate(new Date());

    collaborator.setStatus(Status.ACTIVE);
    collaborator.setRegistration(new Date());
    collaborator.setLastUpdate(new Date());

    collaboratorRepository.create(collaborator);
}

From source file:io.fabric8.elasticsearch.plugin.acl.BaseRolesSyncStrategyTest.java

@Test
public void testFormatUserNameRoleThatHasSlash() {
    assertEquals("gen_user_" + DigestUtils.sha1Hex("test\\\\user"), formatUserRoleName("test\\\\user"));
}

From source file:GetSHA.java

public static String CrackThisFixedlen(String input, int pwlength) {
    // Cracks a hash to find a password of fixed length pwlength.
    // Called by CrackThisVarlen or call it directly if you know how long it is.

    System.out.println("Started at " + ShowDate());

    String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,./;'<>?:@[]\\{}|!\"`~#$%^&*()_+-=";

    // init array
    int[] ticker = new int[pwlength]; // arrays of int are automatically filled with zeroes
    int i = pwlength - 1;

    while (i >= 0) {
        // set up my attempt
        String attempt = "";
        for (int a = 0; a < pwlength; a++)
            attempt += chars.charAt(ticker[a]);

        // attempt is in 'attempt' - now see if it matches

        if (DigestUtils.sha1Hex(attempt).equals(input)) {
            System.out.println("Finished with positive result at " + ShowDate());
            return attempt;
        }//from  ww w.j av  a 2s.co m

        //increment the characters in the attempt

        if (ticker[i] == chars.length() - 1) {
            // reset and move left
            ticker[i] = 0;
            i--;
        } else {
            // increment and ensure i is looking at the end of the string
            ticker[i]++;
            i = pwlength - 1;
        }
    }
    System.out.println("Finished with null result at " + ShowDate());
    return null;
}