gpt4 book ai didi

Java AES-128 ECB 加密

转载 作者:行者123 更新时间:2023-12-02 10:35:25 31 4
gpt4 key购买 nike

我收到了一条来自 AT5 (Atrack) unite 的消息,该消息使用 AES-128 ECB 加密进行编码,这是十六进制 key (33333838000000000000000000000000)原始 key 位于字符串“3388”中这是我收到的密码,但我将其转换为十六进制

每当我尝试解密消息时,我都会遇到以下异常:

Error while decrypting: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher

这是我的代码:

    orginalString 

?U??????}MgD?R???`????
#?j????g:N???@???$=???r?u?>~??Qh,?N?????3?8:?-E??;?b<J??I?v{?'o?m[?|?CY?n????K????>?ã??<?,???? ??f?'???}&?}?7r%??93??!u?0D?3Ig|??%'????*??`?Y^?M?4J?I?>?tIu???;?RR;2??{nrl??us
?R?F?oi????



String strToDecrypt = "E255898281B7C0B67D4D6744DB52FA1789F760B99B86A40A1F238B6ABCC690C1C9673A4E07EA03F79B40B2ACC8243DD098F4B10E72BA75CE3E7EE50F935168042CC74EA2F4BBE3D833F4383AE02D45C0119C3BC8623C4AD5189249FAB0BB767BA2276FB56D5BF27CE017435901DD8F6EC9DECD05B74BF51A99B1933E89C3A3AD06CA893CE72CDDEAE5F509E2D01B66A02717AADD0C917D26BA7DB1377225CCF23933E5F92175BD3044C63349677CEBC6251B27BE1FC9FD7FC32A0785F36019C2595E1EE783B64DB2344A14CE49C63EAB74174975FCE1C53BD95252113B0332CBD7A37B6E726CCFF675730DB052B14605E36F69AF11E8F3D2002D8BABEFFF508187E4C176329A3ABE08CF2B9A9F4812CF4084BACE87AD116F49C2ACD449767E758CE9184C60268AE3AAEADA052C91BF16241682E333671AC209D5BDC34CFD2B2D0C8D6D795D36A5FBD707FB56F71B3740BA86B1CEAC6E784E8E2B999CC6C9260A13F697A115C80F29C5AA38E95964731073CB051BB8A201EBAE6443A057AA69CFF41C9A593F88E2D6A712107EABCDE7042134F818268BF31896072C1B399B878BACCECC096F79A8D1835C2766EA639341E4AB22820D5AAD0F202BC896BD6C6F4D1FB1873C5BE06278D11E67F577D0120E054971088E7DB7E3A8139B20C6E22B86205BC0F4778A1DA0D6E50416FCE55DBC576A9F907FC706148204CA3C79993A4F37756427871C12EB379B4BFA0A518FFCA2BC698B1CA68AC9B3548B241C12669CEFAC9C8ECDB7B5A8149B";
secretKey = new SecretKeySpec("33333838000000000000000000000000".getBytes("UTF-8"), "AES");

Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
byte[] cipherResult = cipher.doFinal(Base64.decodeBase64(strToDecrypt));

最佳答案

你的strToDecrypt似乎是十六进制编码,而不是base64编码..所以你需要在解密之前对其进行十六进制解码,而不是base64解码。但实际上,如果十六进制解码,您加密的数据最终也会得到无效的大小。您的十六进制字符串是 1200 个十六进制字符 = 600 个字节 = 37.5 个 16 字节的 AES block .. 您的数据似乎有问题 ..

此外,您的 key 也是十六进制编码的,因此您需要对其进行十六进制解码..而不仅仅是执行 getBytes(..)

关于Java AES-128 ECB 加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53322829/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com