首页 > 其他分享 >Navicat Premium密码查看,密码解密

Navicat Premium密码查看,密码解密

时间:2024-03-27 15:22:39浏览次数:14  
标签:Premium String currentVector Navicat 密码 cipher result new byte

在navicat右上角点击文件,点击导出链接,导出ncx文件,在文件找到password的加密字符

 将以下代码复制到https://www.runoob.com/try/runcode.php?filename=HelloWorld&type=java中,执行后,即可解密。
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.MessageDigest;
import java.util.Arrays;
 
public class NavicatPassword {
    public static void main(String[] args) throws Exception {
        NavicatPassword navicatPassword = new NavicatPassword();
 
        // 11版本及以前的密码,填写在""中,本例以11的密码为例
        String decode = navicatPassword.decrypt("CE3AAB73CBBE383C", 11);
 
        // 12版本及以后的密码,填写在""中
        //String decode = navicatPassword.decrypt("15057D7BA390", 12);

        System.out.println(decode);
    }

 
    private static final String AES_KEY = "libcckeylibcckey";
    private static final String AES_IV = "libcciv libcciv ";
    private static final String BLOW_KEY = "3DC5CA39";
    private static final String BLOW_IV = "d9c7c3c8870d64bd";
 
    public static String encrypt(String plaintext, int version) throws Exception {
        switch (version) {
            case 11:
                return encryptEleven(plaintext);
            case 12:
                return encryptTwelve(plaintext);
            default:
                throw new IllegalArgumentException("Unsupported version");
        }
    }
 
    public static String decrypt(String ciphertext, int version) throws Exception {
        switch (version) {
            case 11:
                return decryptEleven(ciphertext);
            case 12:
                return decryptTwelve(ciphertext);
            default:
                throw new IllegalArgumentException("Unsupported version");
        }
    }
 
    private static String encryptEleven(String plaintext) throws Exception {
        byte[] iv = hexStringToByteArray(BLOW_IV);
        byte[] key = hashToBytes(BLOW_KEY);
 
        int round = plaintext.length() / 8;
        int leftLength = plaintext.length() % 8;
        StringBuilder result = new StringBuilder();
        byte[] currentVector = iv.clone();
 
        Cipher cipher = Cipher.getInstance("Blowfish/ECB/NoPadding");
        SecretKeySpec secretKeySpec = new SecretKeySpec(key, "Blowfish");
        cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);
 
        for (int i = 0; i < round; i++) {
            byte[] block = xorBytes(plaintext.substring(i * 8, (i + 1) * 8).getBytes(), currentVector);
            byte[] temp = cipher.doFinal(block);
            currentVector = xorBytes(currentVector, temp);
            result.append(bytesToHex(temp));
        }
 
        if (leftLength > 0) {
            currentVector = cipher.doFinal(currentVector);
            byte[] block = xorBytes(plaintext.substring(round * 8).getBytes(), currentVector);
            result.append(bytesToHex(block));
        }
 
        return result.toString().toUpperCase();
    }
 
    private static String encryptTwelve(String plaintext) throws Exception {
        byte[] iv = AES_IV.getBytes();
        byte[] key = AES_KEY.getBytes();
 
        Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
        SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
        IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
        cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
 
        byte[] result = cipher.doFinal(plaintext.getBytes());
        return bytesToHex(result).toUpperCase();
    }
 
    private static String decryptEleven(String ciphertext) throws Exception {
        byte[] iv = hexStringToByteArray(BLOW_IV);
        byte[] key = hashToBytes(BLOW_KEY);
        byte[] encrypted = hexStringToByteArray(ciphertext.toLowerCase());
 
        int round = encrypted.length / 8;
        int leftLength = encrypted.length % 8;
        StringBuilder result = new StringBuilder();
        byte[] currentVector = iv.clone();
 
        Cipher cipher = Cipher.getInstance("Blowfish/ECB/NoPadding");
        SecretKeySpec secretKeySpec = new SecretKeySpec(key, "Blowfish");
        cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
 
        for (int i = 0; i < round; i++) {
            byte[] block = Arrays.copyOfRange(encrypted, i * 8, (i + 1) * 8);
            byte[] temp = xorBytes(cipher.doFinal(block), currentVector);
            currentVector = xorBytes(currentVector, block);
            result.append(new String(temp));
        }
 
        if (leftLength > 0) {
            currentVector = cipher.doFinal(currentVector);
            byte[] block = Arrays.copyOfRange(encrypted, round * 8, round * 8 + leftLength);
            result.append(new String(xorBytes(block, currentVector)));
        }
 
        return result.toString();
    }
 
    private static String decryptTwelve(String ciphertext) throws Exception {
        byte[] iv = AES_IV.getBytes();
        byte[] key = AES_KEY.getBytes();
        byte[] encrypted = hexStringToByteArray(ciphertext.toLowerCase());
 
        Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
        SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
        IvParameterSpec ivParameterSpec = new IvParameterSpec(iv);
        cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
 
        byte[] result = cipher.doFinal(encrypted);
        return new String(result);
    }
 
    private static byte[] xorBytes(byte[] bytes1, byte[] bytes2) {
        byte[] result = new byte[bytes1.length];
        for (int i = 0; i < bytes1.length; i++) {
            result[i] = (byte) (bytes1[i] ^ bytes2[i]);
        }
        return result;
    }
 
    private static byte[] hexStringToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len / 2];
        for (int i = 0; i < len; i += 2) {
            data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
                    + Character.digit(s.charAt(i + 1), 16));
        }
        return data;
    }
 
    private static byte[] hashToBytes(String s) throws Exception {
        return MessageDigest.getInstance("SHA-1").digest(s.getBytes());
    }
 
    private static String bytesToHex(byte[] bytes) {
        StringBuilder result = new StringBuilder();
        for (byte b : bytes) {
            result.append(String.format("%02X", b));
        }
        return result.toString();
    }
}

 

 

标签:Premium,String,currentVector,Navicat,密码,cipher,result,new,byte
From: https://www.cnblogs.com/jxba/p/18099388

相关文章

  • Rat cat9忘记root密码,使用Shell修改root密码
    打开虚拟机按e进入GRUB编辑模式将rhgbquiet用init=/bin/sh 替换按CTRL+X启动系统出现bash-5.1输入命令(1)执行以下命令以可写方式重新挂载根目录:mount-oremount,rw/(2)执行以下命令修改root密码:passwdroot(3)如果系统启动了SELinux,必须执行以下命令,否则将......
  • 维吉尼亚密码
    在一个凯撒密码中,字母表中的每一字母都会作一定的偏移,例如偏移量为3时,A就转换为了D、B转换为了E……而维吉尼亚密码则是由一些偏移量不同的恺撒密码组成。 为了生成密码,需要使用表格法。这一表格(如图1所示)包括了26行字母表,每一行都由前一行向左偏移一位得到。具体使用哪......
  • 密码引擎
    解压源代码tarxzvf openssl-3.2.1.tar.gz进入源代码目录:cdopenssl-3.2.1编译安装:./configuremakesudomakeinstallWindows中编译openssl......
  • 移动宽带光猫—获取超级管理员密码教程
    设备名称:吉比特无源光纤接入用户端设备(GPONONU)设备类型:中国移动智能家庭网关类型八设备型号:H5-8默认终端配置地址:192.168.1.1默认终端配置账号:user默认终端配置密码:************ 第一步、先用普通用户登录http://192.168.1.1输入账号:user输入密码:*******......
  • fedora cloud image设置密码方法
    上网下了个fedoracloudimage的qcow2文件,起来虚机后没法登陆,也没有默认密码,后来发现是给云服务用的,要用cloud-init来初始化密码,本机上可以建个iso来初始化1.Createafilecalled"meta-data"withthecontentsinstance-id:iid-local01;local-hostname:fed21;2.Create......
  • C语言:洛谷题目分享(4)小书童--凯撒密码和笨小猴
    目录1.前言2.俩道题目1.小书童--凯撒密码1.题目背景2.题目描述3.输入格式4.输出格式5.题解2.笨小猴1.题目描述2.输入格式3.输出格式4.题解3.小结1.前言哈喽大家好啊,今天我继续为大家分享洛谷题单的俩道题目,请大家多多支持喔~2.俩道题目1.小书童--凯撒密码......
  • 前端实现用户名密码国家注册(Eclipse Jee软件)
    <!DOCTYPEhtml><html><head><metacharset="UTF-8"><scriptsrc="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script><title>注册页面</title></head><body> <lab......
  • 应用密码学——分组密码
    DES算法描述明文分组为64位,初始密钥64位,有效密钥56位,输出密文64位,16轮迭代的分组对称密码算法。由置换、替换、异或、循环移位组成。流程图加密过程密钥生成64位初始密钥先进行一个PC-1置换,目的是根据置换表去掉8位奇偶校验位,并打乱剩下的56位有效密钥的顺序。将这56位分......
  • 忘记gitlab代码仓库登录密码,如何找回?
    一、密码要求必须是管理员或者自管理的Gitlab实例密码长度限制:Minimum:8charactersMaximum:128characters避免使用弱密码:例如gitlab、人名 二、密码找回方式2.1使用UI【适用普通账号】使用root账号,登录后,进入到管理中心。 搜索到用户后,点击编辑按钮 编辑态......
  • 信息安全技术第2章——密码技术
    2.1密码学基础2.1.1密码学历史及密码系统组成密码系统的四个基本部分组成明文:要被发送的原文消息密码算法:由加密和解密的数学算法组成密文:明文经过加密算法加密之后得到的结果密钥:在加密和解密过程中使用的一系列比特串​​​​​​​2.1.2密码的作用实现信息的保密性......