小编Joã*_*ade的帖子

为什么RSA使用相同的密钥和消息产生不同的结果?

我会发布我的代码.对困惑感到抱歉.

StringBuilder texto1 = new StringBuilder("LALALLA");
byte[] x = texto1.toString().getBytes();
try {
  Cipher cifrado = Cipher.getInstance("RSA/ECB/PKCS1Padding");
  cifrado.init(Cipher.ENCRYPT_MODE, key1.getPublic());
  x = cifrado.doFinal(x);
  String texto;
  texto = new String(x, "UTF-8");
  JOptionPane.showInputDialog(publicKey.toString());
  String teste = "";
  for (int i = 0; i < x.length; i++) {
    teste += x[i];
  }
  jTextPane1.setText(teste);
  //cifrado.init(Cipher.DECRYPT_MODE, privatekey);
  byte[] y;
  // x= texto.getBytes();
  //y = cifrado.doFinal(texto.getBytes());
  //texto = new String(y,"UTF-8");
  jTextPane2.setText(x.toString());
} ...
Run Code Online (Sandbox Code Playgroud)

这是按钮操作中的代码.每次运行此代码时,使用相同的密钥,texto1 on encryption会返回不同的结果,如[B@52a0b1e1[B@3e55abb3

java arrays encryption rsa character-encoding

2
推荐指数
1
解决办法
791
查看次数

在 C 中的函数参数内定义数组

有没有办法在 C 中的函数参数内定义数组?像这样的东西:

void arraysomething(double vec[2]){
    //do something...
}

int main(){
    arraysomething({1.,2.});
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我到处寻找,却一无所获。

c

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

我正在努力理解为什么当我更改列表中的某些值时某些 Lisp 数据会发生变化而其他的则不会

我正在努力理解为什么当我更改 l1 列表的值时,双参数宏会更改结果列表中的值而双列表不会。让我把步骤展示得更清楚。我已经用值 '(1 2 3 4) 定义了列表 l1,

(setq l1 '(1 2 3 4))
Run Code Online (Sandbox Code Playgroud)

然后我在下面加载这个代码

    (defmacro double-args (&rest args)
`(let ((ret nil))
    ( dolist (x ,@args )
        (setq ret (append ret (list x x))))
    
   ret) )

(defun macroteste (&rest x) (double-args x))

 ;; first simple macro example:

(defmacro double-list (a-list)
  (let ((ret (gensym)))
   `(let ((,ret nil))
     (dolist (x ,a-list)
      (setq ,ret (append ,ret (list x x))))
 ,ret)))

 ;; use the macro:

 (defun doublelistmacro (x)
  (double-list x))
Run Code Online (Sandbox Code Playgroud)

在此之后,我执行了宏,macroteste 与列表 l1 …

lisp clisp common-lisp

0
推荐指数
1
解决办法
69
查看次数

标签 统计

arrays ×1

c ×1

character-encoding ×1

clisp ×1

common-lisp ×1

encryption ×1

java ×1

lisp ×1

rsa ×1