Here you can find the source of digestSha256(String value)
Parameter | Description |
---|---|
value | The source string to parse. |
public static byte[] digestSha256(String value)
//package com.java2s; /*// www . j av a 2 s .c o m // This software is subject to the terms of the Eclipse Public License v1.0 // Agreement, available at the following URL: // http://www.eclipse.org/legal/epl-v10.html. // You must accept the terms of that agreement to use this software. // // Copyright (C) 2001-2005 Julian Hyde // Copyright (C) 2005-2012 Pentaho and others // All Rights Reserved. */ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /** * Parses a string and returns a SHA-256 checksum of it. * * @param value The source string to parse. * @return A checksum of the source string. */ public static byte[] digestSha256(String value) { final MessageDigest algorithm; try { algorithm = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } return algorithm.digest(value.getBytes()); } }