Похожие чаты

Keep it 'B', but do bArr[i2] = num + 128

instead of bArr[i2] = num
What's the output then?

2 ответов

14 просмотров

Finfally solve the problem In java keyInBytes = keyToBytes("7e585aedb1dd597382cf5aaaabfa221d") returned byte array is [126, 88, 90, -19, -79, -35, 89, 115, -126, -49, 90, -86, -85, -6, 34, 29] for each value in this array is signed byte in decimal form in range of -128 to + 127 Note that for each pair of two characters 7e 58 5a ed ..... For example, it's converted with Interger.parseInt("ed",16) == int('ed',16) == 237 So, the represented 32 bits signed integer in both Python and Java, they are same But In Java, when the integer 237 was converted to byte, it's by default masked to 237 - 256 = -19 if num > 127: num = num - 256 In Python side ,even substract by 256 and got corresponding masked value -19, it's still a 32 bits singed integer not a signed byte. Solution: key = "7e585aedb1dd597382cf5aaaabfa221d" text = 'hello world' ciphter = AESChiper(key) ret = ciphter.encrypt(text) print(ret) def __init__(self, key): self.bs = 16 self.key = unhexlify(key) ## b'~XZ\xed\xb1\xddYs\x82\xcfZ\xaa\xab\xfa"\x1d' self.keyInHexString = b2a_hex(self.key) ## b'7e585aedb1dd597382cf5aaaabfa221d' def encrypt(self, message): message = self._pad(message) iv = unhexlify('0'*32) cipher = AES.new(self.key, AES.MODE_CBC, iv) return base64.b64encode(cipher.encrypt(message)).decode('utf-8') 64 in hex. Correspondingly, in decimal forms are

the problem is here, return base64.b64encode(iv + cipher.encrypt(message)).decode('utf-8')

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта