小程序 转码工具

package com.jia.sysconfig;


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;


/*
 * 加密解密软件
 * 不使用java风格:JFrame.setDefaultLookAndFeelDecorated(true);
 * 设置窗口位置:this.setLocation(widthSize / 1024 * 850,heightSize / 768 * 100)
 * 窗口位于中央:this.setLocationRelativeTo(null)
 * 窗口大小是否可以拖动:this.setResizable(false)
 * 关闭风格:this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 * 设置窗体风格:
 * UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 * SwingUtilities.updateComponentTreeUI(this);
 * 设置窗口图标:
 * Image image = Toolkit.getDefaultToolkit().createImage("images/001.png");
        this.setIconImage(image);
 * 设置窗口可见:this.setVisible(true)
 * 屏幕尺寸:Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
 * 字体样式大小:nameText.setFont(new Font(null, 0, 12));
 * 设置闪烁的颜色:beforeTranText.setCaretColor(Color.white);
 * 设置背景颜色:nameText.setBackground(Color.red)
 * 设置字体颜色:nameText.setForeground(Color.red)
 * 聚焦:pwdText.requestFocus();
 * 弹出框:JOptionPane.showMessageDialog(this, "请输入密码!", "提示信息", 2);
 * 图片处理:Image image = imageIcon.getImage();
        image = image.getScaledInstance(mainWidth, mainHeight,
                Image.SCALE_DEFAULT);
        imageIcon.setImage(image);
        imageLabel.setIcon(imageIcon);
 */
public class ChineseAndUnicode extends MyListener
{
    /**
     * 定义两个按钮,获取环境变量和获取系统配置
     */
    JButton downTranBtn = new JButton("向下转码");
    JButton upTranBtn = new JButton("向上还原");
    JButton clearBeforeBtn = new JButton("清空▲");
    JButton clearAfterBtn = new JButton("清空▼");
    
    /**
     * 定义两个文本框
     */
    JTextArea beforeTranText = new JTextArea();
    JTextArea afterTranText = new JTextArea();
    
    /**
     * 定义一个面板,存放各组件
     */
    JPanel mainPanel = new JPanel();
    
    /**
     * 定义两个可滚动的面板
     */
    JScrollPane beforePane = new JScrollPane(beforeTranText);
    JScrollPane afterPane = new JScrollPane(afterTranText);
    
    
    /**
     * 获取屏幕尺寸
     */
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    
    int widthSize;
    int heightSize;
    int mainWidthSize;
    int mainHeihgtSize;
     
    {
        widthSize = (int)screenSize.getWidth();
        heightSize = (int)screenSize.getHeight();
        
        mainWidthSize = widthSize / 1024 * 900;
        mainHeihgtSize = heightSize / 768 * 720;     
    }
    
    public ChineseAndUnicode()
    {
        this.setTitle("转码工具");
        this.setSize(mainWidthSize,mainHeihgtSize);
        
        //设置窗口布局
        this.setLayout(new BorderLayout());
        
        //设置窗口是否可以拖动
        this.setResizable(false);
        
        //加载各组件
        this.loadComp();
        
        setDefaultCloseOperation(3);
        
        //设置窗口位置位于中央
        this.setLocationRelativeTo(null);
        
        this.setVisible(true);
    }
    
    /**
     * 加载各个组件
     */
    private void loadComp()
    {   
        mainPanel.setSize(mainWidthSize, mainHeihgtSize);
        mainPanel.setLayout(null);
        mainPanel.setBackground(Color.gray);
        
        int textWidth = widthSize / 1024 * 890;
        int textHeight = this.heightSize / 768 * 350;
        
        //设置背景颜色
        beforeTranText.setBackground(Color.black);
        afterTranText.setBackground(Color.black);
        
        //设置字体颜色
        beforeTranText.setForeground(Color.white);
        afterTranText.setForeground(Color.red);
        
        //设置文本框中闪烁的颜色
        beforeTranText.setCaretColor(Color.white);
        afterTranText.setCaretColor(Color.red);
        
        //设置可以换行
        beforeTranText.setLineWrap(true);
        afterTranText.setLineWrap(true);
        
        beforePane.setBounds(0, 0, textWidth, textHeight);
        afterPane.setBounds(0, heightSize / 768 * 370, textWidth, textHeight);
        
        int btnWidth = widthSize/1024*100;
        int btnHeight = heightSize / 768 * 20;
        clearBeforeBtn.setBounds(widthSize/1024*100, heightSize / 768 * 350, btnWidth, btnHeight);
        downTranBtn.setBounds(widthSize/1024*300, heightSize / 768 * 350, btnWidth, btnHeight);
        upTranBtn.setBounds(widthSize/1024*500, heightSize / 768 * 350, btnWidth, btnHeight);
        clearAfterBtn.setBounds(widthSize/1024*700, heightSize / 768 * 350, btnWidth, btnHeight);
        
        mainPanel.add(beforePane);
        mainPanel.add(afterPane);
        
        mainPanel.add(downTranBtn);
        mainPanel.add(upTranBtn);
        mainPanel.add(clearBeforeBtn);
        mainPanel.add(clearAfterBtn);
        
        clearBeforeBtn.addActionListener(this);
        clearAfterBtn.addActionListener(this);
        downTranBtn.addActionListener(this);
        upTranBtn.addActionListener(this);
        
        this.add(mainPanel);
    }
    
    public static void main(String[] args)
    {
        JFrame.setDefaultLookAndFeelDecorated(true);
        new ChineseAndUnicode();
    }
    
    public void actionPerformed(ActionEvent e)
    {
        //前面文本框的清除按钮
        if (e.getSource() == clearBeforeBtn)
        {
            beforeTranText.setText("");
        }
        //后面文本框的清除按钮
        if (e.getSource() == clearAfterBtn)
        {
            afterTranText.setText("");
        }
        //向下转码按钮
        if (e.getSource() == downTranBtn)
        {
            try
            {
                String strs = beforeTranText.getText();
                strs = chinaToUnicode(strs);
                afterTranText.setText(strs);
            }
            catch (Exception ee)
            {
                JOptionPane.showMessageDialog(this, "含有非法字符不能转化,请检查!", "提示信息", 2);
            }
        }
        
        //向上还原按钮
        if (e.getSource() == upTranBtn)
        {
            try
            {
                String strs = afterTranText.getText();
                strs = unicodeToChinese(strs);
                beforeTranText.setText(strs);
            }
            catch (Exception ee)
            {
                JOptionPane.showMessageDialog(this, "含有非法字符不能转化,请检查!", "提示信息", 2);
            }
        }
    }
    
    /** 
     * 中文转unicode 
     * @param str 
     * @return String 反回unicode编码 
     */  
    private String  chinaToUnicode(String str)
    {
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < str.length(); i++)
        {  
            int chr1 = (char) str.charAt(i);
            //汉字范围 \u4e00-\u9fa5 (中文)
            if(chr1 >= 19968 && chr1 <= 171941)
            {
                result.append("\\u" + Integer.toHexString(chr1));
            }
            else
            {  
                result.append(str.charAt(i)); 
            }  
        }
        return result.toString();
    }  
    
    /** 
     * unicode转中文 
     * @param  str 要转的Unicode字符串
     * @return String 转化后的字符串
     * @throws IOException 
     * @throws InterruptedException 
     */  
    private String unicodeToChinese(String strs) throws IOException, InterruptedException
    {
        File file = new File("C:\\temp");
        if (!file.exists())
        {
            file.mkdir();
        }
        File fileFrom = new File(file,"from.txt");
        File toFrom = new File(file,"to.txt");
        if (!fileFrom.exists())
        {
            fileFrom.createNewFile();
        }
        if (!toFrom.exists())
        {
            toFrom.createNewFile();
        }
        BufferedWriter bw = new BufferedWriter(new FileWriter(toFrom));
        bw.write(strs);
        
        bw.close();
        
        //运行系统的命令
        Runtime rt = Runtime.getRuntime();
        Process pro = rt.exec("cmd /c native2ascii.exe -reverse C:\\temp\\to.txt > C:\\temp\\from.txt");
        pro.waitFor();
        
        //toFrom.delete();
        
        BufferedReader br = new BufferedReader(new FileReader(fileFrom));
        StringBuffer sb = new StringBuffer();
        
        String readStr = br.readLine();
        while (null != readStr)
        {
            sb.append(readStr);
            sb.append("\n");
            
            readStr = br.readLine();
        }
        br.close();
        //System.out.println(sb.toString());
        
        //fileFrom.delete();
        
        return sb.toString();  
     }  

}




package com.jia.sysconfig;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;


import javax.swing.JFrame;


public class MyListener extends JFrame implements ActionListener,MouseListener
{


    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;


    @Override
    public void mouseClicked(MouseEvent e)
    {
        // TODO Auto-generated method stub
        
    }


    @Override
    public void mousePressed(MouseEvent e)
    {
        // TODO Auto-generated method stub
        
    }


    @Override
    public void mouseReleased(MouseEvent e)
    {
        // TODO Auto-generated method stub
        
    }


    @Override
    public void mouseEntered(MouseEvent e)
    {
        // TODO Auto-generated method stub
        
    }


    @Override
    public void mouseExited(MouseEvent e)
    {
        // TODO Auto-generated method stub
        
    }


    @Override
    public void actionPerformed(ActionEvent e)
    {
        // TODO Auto-generated method stub
        
    }
    
}

介绍一下这个软件的目前功能 功能详解: 1:最重要的功能,也就是小程序转码(由于是官方接口,部分只取路径不转码的为手动转码都不可以的,当然机器人也实现不了) 2:一键查询群ID(此功能用于自动加好友拉指定群和发送关键词拉指定群) 3:关键词加群(如上,我见还有人专门另外写个插件另外推广,我的直接在一个软件内) 4:扫码登录小程序账号和接收登录小程序账号(扫码模式直接点击登录公众号会出现一个二维码在软件内,直接扫码登录,接收模式要提前设置一个WXID,给你的机器人发送登录公众号即可自动给你指定的wxid也就是微信号发送一个登录二维码,此举是为了免登服务器,且如果ck到期会自动提醒接收人) 5:自动加好友 6:加上好友自动发送指定消息或图片,或两者并存,且自定义拉群 7:自定义水印(可设置为群水印,私聊水印,这两种模式下又分为转码人的用户名和自定义水印,自定义水印主用于引流) 8:群聊和私聊都可以转二维码模式,别人分享给你网址或者直接发你链接即可转二维码,前提是前缀加http或者https协议头如:https://www.baidu.com 9:二维码转链接模式,发送二维码即可自动解析二维码要跳转的地址,也就是取链接. 10:自动生成appid功能,这个功能其实没啥用,我用于自己的发布活动平台跳转用的,所以加了个. 11:自定义是否关闭私聊功能(此功能折中意见,防止和公众号互怼!) 12:获取小程序路径,一目了然查看邀请链接邀请码,更方便薅羊毛 13:进群@通知并赠送点数(用于收费模式,如下) 14:重点推行的功能,也就是收费模式!支持私聊转码收费和群聊转码收费(转小程序码和转二维码均可设置,且价格自定义)新人加群送多少次数,邀请人进群送多少次数 15:消费提醒,当然这个也没什么卵用,之前定制的客户要的功能,就保留了. 16:这个需要留意:如果收费功能群里面要想转码的需要发送:创建账号 这四个字,否则不能转码,因为这个免费实行给你们,你们的客户无法在我这付费,只能给你们采取这个加数据表的功能,让数据库可以记录付费者的余额.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值