我编码了 HMAC 解密。我多次尝试解密输出。
这是我的代码
package javaapplication_HMAC;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import com.sun.org.apache.xml.internal.security.utils.Base64;
import java.util.Formatter;
public class Encryption {
public void Encryption_Base64(String x,String y){
String message = x;
String key = y;
String algorithm = "HmacSHA1";
try {
Mac sha256_hmac = Mac.getInstance(algorithm);
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), algorithm);
sha256_hmac.init(secret_key);
String hash = Base64.encode(sha256_hmac.doFinal(message.getBytes("UTF-8")));
System.out.println(hash);
} catch (NoSuchAlgorithmException | UnsupportedEncodingException | InvalidKeyException e) {
e.printStackTrace();
}
}
public static void main(String args[]) {
Encryption encryption_base64 = …Run Code Online (Sandbox Code Playgroud)