⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 digestlib.java

📁 Java游戏高级编程!!很不错的!!!Java游戏高级编程!!很不错的
💻 JAVA
字号:
     package com.croftsoft.core.security;

     import java.io.*;
     import java.security.*;

     /*********************************************************************
     * Static method library for creating message digests of byte streams.
     *
     * @version
     *   2003-03-27
     * @since
     *   1998-10-04
     * @author
     *   <a href="http://croftsoft.com/">David Wallace Croft</a>
     *********************************************************************/

     public final class  DigestLib
     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////
     {

     public static byte [ ]  digest (
       InputStream  inputStream,
       String       algorithm )
       throws IOException, NoSuchAlgorithmException
     //////////////////////////////////////////////////////////////////////
     {
       BufferedInputStream  bufferedInputStream
         = new BufferedInputStream ( inputStream );

       MessageDigest  messageDigest
         = MessageDigest.getInstance ( algorithm );

       int  i;

       while ( ( i = bufferedInputStream.read ( ) ) > -1 )
       {
         messageDigest.update ( ( byte ) i );
       }

       bufferedInputStream.close ( );

       return messageDigest.digest ( );
     }

     public static byte [ ]  digest (
       File    file,
       String  algorithm )
       throws IOException, NoSuchAlgorithmException
     //////////////////////////////////////////////////////////////////////
     {
       return digest ( new FileInputStream ( file ), algorithm );
     }

     public static byte [ ]  digest ( File  file )
       throws IOException, NoSuchAlgorithmException
     //////////////////////////////////////////////////////////////////////
     {
       return digest ( file, "SHA-1" );
     }

     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////

     private  DigestLib ( ) { }

     //////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////
     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -