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

📄 main.java

📁 SHA512 is a hash function. You can use sha512 with an asymetric method to sign a document.
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package sha512;/** * * @author mokaddem */public class Main {    /**     * @param args the command line arguments     */    public static void main(String[] args) {       String test_message="";//abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";       for(int i=0;i<1000000;i++)test_message+="a";       byte[]byte_message=test_message.getBytes();       int message_length=test_message.length();       int l=test_message.length()*8;       int k=((896-1-l)%1024);       if (k<0)k+=1024;       int k8=(k-7)>>>3;       int nombre_bytes=message_length+k8+1+16;              byte normal[]=new byte[nombre_bytes];              //on va remplir le tableau        System.arraycopy(byte_message, 0, normal, 0, message_length);       normal[message_length]=(byte) (0x80);       for(int i=1;i<=k8+12;i++)normal[message_length+i]=(byte)(0x00);       for(int i=1;i<=4;i++)normal[message_length+k8+12+i]=(byte)( l>>>(8*(4-i)) );              long [] in=new long [16];       int s=0;       long sha[]=new long[8];       sha[0]=0x6a09e667f3bcc908L;       sha[1]=0xbb67ae8584caa73bL;       sha[2]=0x3c6ef372fe94f82bL;       sha[3]=0xa54ff53a5f1d36f1L;       sha[4]=0x510e527fade682d1L;       sha[5]=0x9b05688c2b3e6c1fL;       sha[6]=0x1f83d9abfb41bd6bL;       sha[7]=0x5be0cd19137e2179L;                     for (int j=0;j<(nombre_bytes>>>7);j++){                        for(int i=0;i<16;i++){                          in[i]=  (long)normal[s++]<<56|((long)(normal[s++]&0xFF))<<48                        |((long)normal[s++]&0xFF)<<40|((long)normal[s++]&0xFF)<<32                        |((long)normal[s++]&0xFF)<<24|((long)normal[s++]&0xFF)<<16                        |((long)normal[s++]&0xFF)<<8|((long)normal[s++]&0xFF);              }            sha=sha512.sha_512 (sha,in);                                        }         for (int m=0;m<8;m++) System.out.println(Long.toHexString(sha[m])+" ");                 }                     }

⌨️ 快捷键说明

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