小编Nem*_*vic的帖子

Java AES加密和解密

我想使用带有16字节密钥的128位AES加密来加密和解密密码.我javax.crypto.BadPaddingException在解密值时遇到错误.在解密时我错过了什么吗?

public static void main(String args[]) {
    Test t = new Test();
    String encrypt = new String(t.encrypt("mypassword"));
    System.out.println("decrypted value:" + t.decrypt("ThisIsASecretKey", encrypt));
}

public String encrypt(String value) {
    try {
        byte[] raw = new byte[]{'T', 'h', 'i', 's', 'I', 's', 'A', 'S', 'e', 'c', 'r', 'e', 't', 'K', 'e', 'y'};
        SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
        Cipher cipher = Cipher.getInstance("AES");
        cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
        byte[] encrypted = cipher.doFinal(value.getBytes());
        System.out.println("encrypted string:" + (new String(encrypted)));
        return new String(skeySpec.getEncoded());
    } catch (NoSuchAlgorithmException ex) …
Run Code Online (Sandbox Code Playgroud)

java encryption aes

24
推荐指数
3
解决办法
10万
查看次数

JavaFX图形设备初始化失败:es2,sw

所以我制作了一个在IDE中运行良好的小型JavaFX项目.但是当在runnable jar中导出时不会双击运行.

在终端我得到以下错误.我在64位系统上运行Ubuntu 15.04.

我已经做了很多谷歌搜索并安装了GTK3GTK2库.我知道这是这个问题的副本,但我认为它已经过时了,而且没有对我有帮助的方法.

我尝试将外部jar添加到我的项目中,如gtk.jar,swt.jar,swt-gtk-java3.8.jar,并安装了每个可能的库,如libswt-gtk-3-java,libgtk2.0,libgtk2.0-dev,libswt-GTK的Java-2,libgtk-3-dev的,libgtk-3libswt-GTK -4-的java.

Bellow是使用标志的终端中的详细错误消息-Dprism.verbose=true.

    Prism pipeline init order: es2 sw 
Using java-based Pisces rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline …
Run Code Online (Sandbox Code Playgroud)

java linux user-interface javafx jar

5
推荐指数
1
解决办法
4314
查看次数

标签 统计

java ×2

aes ×1

encryption ×1

jar ×1

javafx ×1

linux ×1

user-interface ×1