Tag: 填充

在2D数组中填充随机数以添加列/行

嗨,人们刚接触Java并且进展缓慢。 我在添加行和列之前尝试使用随机数填充2D数组。 到目前为止,我可以创建数组,显示它,我很确定我有添加位排序。 但是当我尝试用随机数填充它时,我得到了一个outofboundsexception。 我哪里错了? public static void main(String[] args) { //create the grid final int row = 9; final int col = 9; int [][] grid = new int [row][col]; //fill the grid for (int i=0; i<grid.length; i++) grid[i][grid[i].length] = (int)(Math.random()*10); //display output for(int i=0;i<grid.length; i++) { for(int j=0; j<grid[i].length; j++) System.out.print(grid[i][j]+””); System.out.println(); } […]

如何在jtextfield中添加填充

如何在jtextfield中添加一些填充? 我试过tf.setMargin(new Insets(5,5,5,5)); 这没有任何影响。

Android – 在解密中删除填充的位

我正在使用我自己的自定义加密方法处理安全应用程序,并且在解密消息时遇到问题。 根据该理论,必须填充输入以满足执行加密所需的位。 但填充的位在解密后仍保持不变。 这是一个例子: input (before padding) : q input (after padding) : 113 0 0 0 0 0 0 0 (in Bytes) 然后我执行一些代码: bytes[] a = encrypt(input); bytes[] b = decrypt(a); String output = “”; output = new String(b, “UTF-8”); System.out.println上的输出如下: b : 113 0 0 0 0 0 0 0 output : q[][][][][][][] […]

javax.crypto.BadPaddingException:给定最终块未正确填充

我必须在我的服务器上解密一个帧。 加密帧来自客户端设备通过套接字上的GPRS。 使用TripleDes和给定密钥进行加密。我在服务器端使用相同的算法和密钥。 Frame是Hex和Ascii String的组合。 现在的问题是:当我用零填充我的字节数组时,我得到以下exception。 javax.crypto.BadPaddingException: Given final block not properly padded 以下是我的代码: byte[] key = new byte[]{31, 30, 31, 36, 32, 11, 11, 11, 22, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}; myKeySpec = new DESedeKeySpec(key); mySecretKeyFactory = SecretKeyFactory.getInstance(“TripleDES”); de = mySecretKeyFactory.generateSecret(myKeySpec); Cipher c = […]

JavaFX填写表视图不可能

我刚开始使用javafx,我想创建一个包含3列的TableView ,我可以在其中显示一些值。 我用场景编辑器创建了TableView和列作为fxml文件。 然后我创建了一个名为Values的类,它具有与它们应该适合的列匹配的特殊属性。最后,我将可观察列表中的“Value”对象设置为表项。 当我启动应用程序时,它只显示一个空表。 我现在在网上看了4个小时,仍然没有找到答案为什么这对我不起作用。 这是我的代码: 价值等级: public class Values { public SimpleDoubleProperty PSI = new SimpleDoubleProperty(0); public SimpleDoubleProperty ALPHA = new SimpleDoubleProperty(0); public SimpleDoubleProperty DELTA = new SimpleDoubleProperty(0); public Values(Double _PSI, Double _ALPHA, Double _DELTA) { setPSI(_PSI); setALPHA(_ALPHA); setDELTA(_DELTA); } private void setPSI(Double p){ PSI.set(p); } private void setALPHA(Double p){ ALPHA.set(p); } private […]

为什么我在解密时会收到’BadPaddingException’?

这是我的加密设置: public static String encryptionAlgorithm = “AES”; public static short encryptionBitCount = 256; public static int encryptionMessageLength = 176; public static String hashingAlgorithm = “PBEWITHSHAAND128BITAES-CBC-BC”; //PBEWithSHA256And256BitAES-CBC-BC”PBEWithMD5AndDES”;//”PBKDF2WithHmacSHA1″; public static short hashingCount = 512; public static String cipherTransformation = “AES/CBC/PKCS5Padding”; 这是我的解密代码: public byte[] readMessage () throws Exception { byte[] iv = new byte[16]; byte[] message = new […]

没有填充的Java AES

在没有自动填充的情况下,AES加密和解密16字节数组有哪些最简单的方法? 我找到了使用外部库的解决方案,但我希望尽可能避免这种情况。 我目前的代码是 SecretKeySpec skeySpec = new SecretKeySpec(getCryptoKeyByteArray(length=16)); // 128 bits Cipher encryptor = Cipher.getInstance(“AES”); encryptor.init(Cipher.ENCRYPT_MODE, skeySpec); byte[] encrypted = encryptor.doFinal(plain); 如何防止填充? plain数据总是固定长度并包含自己的填充。 如何在不使encrypted成为32字节的情况下允许plain为16字节?

为什么Java对象必须是8的倍数?

我知道Java使用填充; 对象必须是8个字节的倍数。 但是,我没有看到它的目的。 它是干什么用的? 它的主要目的究竟是什么?

java中的密码填充字符串是什么?

每个人都在讨论密码中的填充方案,但是需要传递给密码的实际字符串是什么? 我不在乎它们是对称的还是非对称的,我只想要一个可能的值列表。

无法设置填充颜色Apache POI Excel工作簿

我一遍又一遍地扫描了这个论坛并尝试了这里提到的所有方法,但仍然无法让Apache POI更改以填充我的Excel文档的背景颜色。 这是我的代码: errorOccured = true; XSSFCellStyle cs = workbook.createCellStyle(); cs.setFillBackgroundColor(IndexedColors.RED.getIndex()); row.getCell(0).setCellStyle(cs); 你知道为什么这不起作用吗? 将row.getCell(0)填充为红色(背景色)的正确方法是什么? 谢谢!