小编Kla*_* 71的帖子

Arduino:连接字符串时崩溃和错误

我尝试将AES-256加密的输出连接到一个字符串(将此字符串与从Android手机发送的加密字符串进行比较).

基本上,连接似乎有效,但经过几次运行错误(不可读的字符,字符串变短而不是更长)或崩溃发生.它是可重现的,在重启后在完全相同的点崩溃.

我提取了一些演示问题的Arduino代码.它执行以下操作:

  1. 创建一个随机数并将其写入数组(工作)
  2. AES-编码此阵列(工作)
  3. 构建每个数组索引的HEX表示(工作)
  4. 将索引连接到String(崩溃)

#include <SPI.h>
#include "aes256.h"  //include this lib

uint8_t key[] = {9,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,
                 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8 }; //the encryption key

aes256_context ctxt; //context needed for aes library


void setup() {  
  Serial.begin(9600);  
}


void loop() {

  uint8_t data[] = {
       0x53, 0x73, 0x64, 0x66, 0x61, 0x73, 0x64, 0x66,
       0x61, 0x73, 0x64, 0x66, 0x61, 0x73, 0x64, 0x65, }; //the message to be encoded  

  long InitialRandom = random(2147483647); //0 to highest possible long
  String RandomString = "" ; 
  RandomString+=InitialRandom; //random …
Run Code Online (Sandbox Code Playgroud)

string arduino string-concatenation

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

将列表转换为数组

我想创建一个包含列表中所有URL的字符串数组.

我有一个存储在列表对象中的URL列表myUrlList.使用myUrlList.toString();返回String表单中的a [http://url1, http://url2, http://url3.....].

此外,myUrlList.getSize()正确返回列表包含的URL数.

如何获取列表中所有URL的数组?我试过了myUrlList.toArray,(String[]) myUrlList.toArray()其他人没有成功.甚至不可能使用获得一个元素myUrlList.get(position).

java arrays android

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

标签 统计

android ×1

arduino ×1

arrays ×1

java ×1

string ×1

string-concatenation ×1