hashmac.java
来自「JAVA的加密源程序」· Java 代码 · 共 32 行
JAVA
32 行
/*Christoforos Pirillos @ Villanova University - May 1999based on code from the book "Java Network Programming" by Hughes*/package encryption;/** Message Authentication Code. It takes an existing hash algorithm andencryption algorithm and combines them to form a MAC*/public class HashMAC extends Hash {protected Hash h;protected Cipher c;public HashMAC (Hash h, Cipher c) { this.h = h; this.c = c;}public byte[] digest (byte[] text, int off, int len) { byte[] hash = h.digest (text, off, len); return c.encipher (hash, 0, Math.min (hash.length,c.blockSize()));}public int digestSize () { return c.blockSize();}}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?