zoukankan      html  css  js  c++  java
  • java.security.Key 在main方法中与在tomcat中得到的encode不同,why?

    public class DESUtils {
    
        private static Key key;
        private static String KEY_STR = "eloan_yzld";
    
        static {
            try {
                KeyGenerator generator = KeyGenerator.getInstance("DES");
                SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
                secureRandom.setSeed(KEY_STR.getBytes());
                generator.init(secureRandom);
    
                key = generator.generateKey();
                byte[] b = key.getEncoded();
                System.out.print("key==============");
                for(int i=0; i<b.length; i++) {
                    System.out.print(b[i] + " ");
                    // 本地main 方法跑得到[-80, -60, 19, -33, 112, -75, -12, 93]
                    // 从tomcat中启动时得到[-26, -92, -62, 25, 55, -125, 14, -42]
                }
                System.out.println();
                generator = null;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    ...
    }

    实在想不明白为什么会这样

    19:40:24

    刚刚把项目打了个war包,扔到linux服务器下跑,结果发现,日志中打出了

    这说明在linux下是正常的

    20:05:47

    实在看不出问题了,一狠心换了个工作空间,完美运行~!

    
    
  • 相关阅读:
    tornado中form表单验证详解
    关于tornado中session的总结
    Linux常用命令
    css3动画属性详解 与超酷例子
    keepalive高可用的健康检查
    keepalive的nginx防火墙问题
    安装配置hadoop
    tmux的简单快捷键
    部署使用elk
    k8s搭建部署
  • 原文地址:https://www.cnblogs.com/goldeneast/p/5939884.html
Copyright © 2011-2022 走看看