发现有个问题,就是在遇到比如\n这种换行符等符号时候,就和之前java的加密结果不一致。如果删掉\n就能得到同样的加密结果。用同样的密码,对同一个内容加密。
密码:718fc3a5e0e1d05a内容:
{"anwser":51.0,"content":"x - 15 = 36\nx = ?","image":"","index":3,"subject":"","tips":""},{"anwser":9.0,"content":"1, 3, 5, 7, ?","image":"","index":4,"subject":"","tips":"后一个数比前一个数+2"}
java测试:
String preContent="{\"anwser\":51.0,\"content\":\"x - 15 = 36\\nx = ?\",\"image\":\"\",\"index\":3,\"subject\":\"\",\"tips\":\"\"},{\"anwser\":9.0,\"content\":\"1, 3, 5, 7, ?\",\"image\":\"\",\"index\":4,\"subject\":\"\",\"tips\":\"后一个数比前一个数+2\"}"; String test1 = BaseAesUtil.aesEncrypt(preContent, "718fc3a5e0e1d05a");
得到的加密结果:test1为:
2423E707876B19976C72ED9EA78EDCF1D5DA8417699A28F9FFCC2448C72FED797B5E77E499C0B9E6F961BDC05A22AF16A5EA2863E151272B66FB8D4A0B00278F4DF0643E55A66A0D81FF244C5D9BCCB6E594BB39234B7701224D773CE73E6D87EA03CF39468C4C92B3A4B2B89D3D946EA44F8A39FD38A96D1C20FAF7B5FC686FFB651D73959B79D35D919AF395D00A688A1E5EC44D8D95CD5BB7A20B83E26DBACF7D68F9E303FC7845B407B6B23EA73BAB4090230166CB07D00EE5D3F64B46252C332ADBDDC858D910287F442E56D22A
let preContent: string = '{"anwser":51.0,"content":"x - 15 = 36\nx = ?","image":"","index":3,"subject":"","tips":""},{"anwser":9.0,"content":"1, 3, 5, 7, ?","image":"","index":4,"subject":"","tips":"后一个数比前一个数+2"}'
let test2 : string = await BAesUtil.aesEncrypt(preContent, '718fc3a5e0e1d05a') as string;
得到的加密结果:test2为:
2423E707876B19976C72ED9EA78EDCF1D5DA8417699A28F9FFCC2448C72FED79DC5B54269865B4692B80A81D80520323849218F04FAC33EFE7B59A97AC55AD81E1E1C36B8A63EE0B3B6C2B3C80A30E528E1A33BF5FDACAD5C2DF7D1579B35D93F0C9134656EF4A838078D1348C8BB189CA17F8753A0A05F525AAE3F5D8F16339F016BC91C9A892470205BCA9F4FE2A088F3A7600933D9D913A12EDCF106B50B64587765AEEB2A951B40F1BF0CEEF1BC458593ED6B29A9A5AD1358C65EC789B7394478B131ABD20B7D0F5EF28EF09E8E7
可以看出加密结果前面相同,大概在有换行符地方就开始不一样了。
AES同步方法代码demo实例如下: