获取Facebook 散列利器 来了 十六进制到 Base64 转换器

前言导读

因为项目中需要获取facebook的散列,又用Google重签包,所以不是很好获取,这边就写了一个十六进制到 Base64 通过签名的里面的sha1 然后转换成哈希值的散列

输入我们的sha1 然后点击 Convent

点击ok 就要生成我们的想要的facebook 散列

具体实现

ini 复制代码
package com.company;
import java.awt.*;
import java.awt.event.*;
import java.util.Base64;


public class Main extends Frame {

    // Component declarations
    private TextArea hexInput;
    private TextArea cleanedHexOutput;
    private TextArea base64Output;
    private Checkbox remove0xCheckBox;

    public Main() {
        super("Hex to Base64 Converter");
        initializeUI();
        setupListeners();
    }

    private void initializeUI() {
        setLayout(new BorderLayout(10, 10));
        setBackground(Color.WHITE);
        setResizable(true);

        // Main panel
        Panel mainPanel = new Panel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.insets = new Insets(5, 5, 5, 5);
        gbc.anchor = GridBagConstraints.NORTHWEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;

        // Hex input area
        gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0;
        mainPanel.add(new Label("Hexadecimal String:"), gbc);

        gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 0.2;
        hexInput = new TextArea(3, 60);
        mainPanel.add(hexInput, gbc);

        // Instruction text
        gbc.gridx = 1; gbc.gridy = 1; gbc.weighty = 0;
        Label noteLabel = new Label("Note: All non-hexadecimal characters will be ignored. Input is case-insensitive.");
        noteLabel.setForeground(Color.GRAY);
        mainPanel.add(noteLabel, gbc);

        // Remove 0x prefix option
        gbc.gridx = 1; gbc.gridy = 2;
        remove0xCheckBox = new Checkbox("Remove "0x" groups from input", true);
        mainPanel.add(remove0xCheckBox, gbc);

        // Cleaned Hex display area
        gbc.gridx = 0; gbc.gridy = 3; gbc.weightx = 0;
        mainPanel.add(new Label("Cleaned Input:"), gbc);

        gbc.gridx = 1; gbc.gridy = 3; gbc.weightx = 1; gbc.weighty = 0.2;
        cleanedHexOutput = new TextArea(3, 60);
        cleanedHexOutput.setEditable(false);
        mainPanel.add(cleanedHexOutput, gbc);

        // Base64 output area
        gbc.gridx = 0; gbc.gridy = 4; gbc.weightx = 0;
        mainPanel.add(new Label("Output (base64):"), gbc);

        gbc.gridx = 1; gbc.gridy = 4; gbc.weightx = 1; gbc.weighty = 0.2;
        base64Output = new TextArea(3, 60);
        base64Output.setEditable(false);
        mainPanel.add(base64Output, gbc);

        // Convert button
        gbc.gridx = 1; gbc.gridy = 5; gbc.weighty = 0;
        gbc.anchor = GridBagConstraints.CENTER;
        Button convertButton = new Button("Convert");
        mainPanel.add(convertButton, gbc);

        add(mainPanel, BorderLayout.CENTER);

        // Set window size and position
        setSize(800, 400);
        setLocationRelativeTo(null); // Center the window

        // Add window closing handler
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                dispose();
            }
        });
    }

    private void setupListeners() {
        // Convert button event handling
        Button convertButton = (Button) ((Panel) getComponent(0)).getComponent(8);
        convertButton.addActionListener(e -> {
            String input = hexInput.getText();
            boolean remove0x = remove0xCheckBox.getState();

            // Clean Hex input
            String cleanedHex = cleanHex(input, remove0x);
            cleanedHexOutput.setText(cleanedHex);

            // Validate that the cleaned Hex length is even
            if (cleanedHex.length() % 2 != 0) {
                showAlert("Error", "The length of the cleaned hexadecimal string is odd.");
                base64Output.setText("");
                return;
            }

            // Convert to Base64
            try {
                String base64 = hexToBase64(cleanedHex);
                base64Output.setText(base64);
            } catch (Exception ex) {
                showAlert("Error", "Conversion failed: " + ex.getMessage());
            }
        });
    }

    /**
     * Cleans the Hex string by removing non-hexadecimal characters and optional 0x prefixes.
     */
    private String cleanHex(String input, boolean remove0x) {
        if (input == null || input.isEmpty()) {
            return "";
        }

        // Convert to uppercase
        input = input.toUpperCase();

        // Remove 0x prefixes if needed
        if (remove0x) {
            input = input.replaceAll("0X", "");
        }

        // Save original input for comparison
        String originalInput = input;

        // Remove all non-Hex characters
        input = input.replaceAll("[^0-9A-F]", "");

        // Show a warning if any non-Hex characters were removed
        if (!originalInput.equals(input)) {
            showAlert("Warning", "Non-hexadecimal characters in the input string have been ignored.");
        }

        return input;
    }

    /**
     * Converts a Hex string to Base64 encoding.
     */
    private String hexToBase64(String hex) {
        if (hex == null || hex.isEmpty()) {
            return "";
        }

        // Convert Hex string to byte array
        byte[] bytes = new byte[hex.length() / 2];
        for (int i = 0; i < bytes.length; i++) {
            int index = i * 2;
            int value = Integer.parseInt(hex.substring(index, index + 2), 16);
            bytes[i] = (byte) value;
        }

        // Encode to Base64
        return Base64.getEncoder().encodeToString(bytes);
    }

    /**
     * Displays an alert dialog.
     */
    private void showAlert(String title, String message) {
        Dialog dialog = new Dialog(this, title, true);
        dialog.setLayout(new FlowLayout());
        dialog.add(new Label(message));

        Button okButton = new Button("OK");
        okButton.addActionListener(e -> dialog.dispose());
        dialog.add(okButton);

        dialog.setSize(300, 150);
        dialog.setLocationRelativeTo(this);
        dialog.setVisible(true);
    }

    public static void main(String[] args) {
        // Run the UI on the Event Dispatch Thread
        EventQueue.invokeLater(() -> {
            new Main().setVisible(true);
        });
    }
}

打包成jar

编译成jar

转成exe

output选择我们的输出的exe路径

选择console

jre 运行时 我们选择相对路径方便 一点

最终效果

我们只需要保证我们的exe 和jre在同一个根目录既可以正常运行

最后总结

工具是方面给我们自己使用或者 运营专员使用,来提升我们的效率,最后我想说的实际 ,我们在现实中 一定要学会使用工具和创造工具,切记重复去做一件事情,大脑和灵魂需要进步和升华,今天的文章就讲到这里有兴趣的同学可以拿老师代码去优化修改, 今天的文章就讲到这里有兴趣的 关注我B站教程 了解更多鸿蒙开发的知识 可以关注坚果派公众号 。 谢谢

项目地址

gitee.com/qiuyu123/he...

相关推荐
我不是混子2 小时前
聊聊Spring事件机制
java·后端
DKPT2 小时前
JVM栈溢出时如何dump栈信息?
java·jvm·笔记·学习·spring
DKPT2 小时前
JVM堆大小如何设置?
java·开发语言·jvm·笔记·学习
铅笔侠_小龙虾2 小时前
JVM 目录
java·jvm
yunxi_052 小时前
让大模型会“说话”:基于 Spring WebSocket 的毫秒级流式 RAG 对话
java·后端
用户6120414922132 小时前
jsp+servlet做的医院挂号看诊管理系统
java·javascript·mysql
€8113 小时前
Java入门级教程21——Java 缓存技术、RMI远程方法调用、多线程分割大文件
java·开发语言·java缓存代理模式的实现·java rmi远程方法调用·多线程分割大文件
渣哥3 小时前
Java线程池那些坑:我与线程池的恩怨情仇
java
hour_go3 小时前
BPEL:企业流程自动化的幕后指挥家
java·运维·自动化