Java SHA1 SHA1(String text)

Here you can find the source of SHA1(String text)

Description

SHA

License

LGPL

Declaration

public static byte[] SHA1(String text) 

Method Source Code


//package com.java2s;
/*/*  w  w w . jav a 2s  .c om*/
 * This file is part of Vapor.
 *
 * Copyright (c) 2013-2013, Snaipe <http://snaipe.me/>
 * Vapor is licensed under the GNU Lesser General Public License Version 3.
 *
 * Vapor is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * Vapor is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 * for the GNU Lesser General Public License.
 */

import java.security.MessageDigest;

public class Main {
    public static byte[] SHA1(String text) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-1");
            md.update(text.getBytes("US-ASCII"), 0, text.length());
            return md.digest();
        } catch (Throwable t) {
            throw new RuntimeException(t); // not happening ever, but you never know...
        }
    }
}

Related

  1. SHA1(String str)
  2. sha1(String string)
  3. sha1(String string)
  4. SHA1(String strs)
  5. sha1(String text)
  6. sha1(String text)
  7. SHA1(String text)
  8. SHA1(String text)
  9. SHA1(String text)