Похожие чаты

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

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

2 ответов

13 просмотров

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')

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

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

Hey everyone! I won’t focus too much on what this person said (it’s clear they don’t understand the scope of what TF and TELOSX are achieving), but I’ll put it simply for thos...
Ana Ojeda
3
как правильно удалить сддм? прописал в etc/portage.use/plasma-meta -sddm , но при обновлении юзов мне предлагает поставить lightdm (ещё лучше 😡), добавил туда - display-manage...
REDis
25
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
Telos is at a pivotal moment. While ambitious projects like zkEVM and SNARKtor have shown promise, the delay in delivering EVM 2.0—a cornerstone of the ecosystem—is a growing ...
Trinidad
8
#include <stdio.h> #include <stdlib.h> #include <time.h> void mass_first_generate(int mass[5][7]) {     for (int N = 0; N < 5; N++) {         for (int A = 0; A < 7; A++) {   ...
Чувак
6
i have a small doubt i developed a rest API in put mapping (we use if more than one filed needs to be updated by user ) but concern is i am using dto class in that i am u...
Surya
6
Всем привет! Решаю 99 OCaml Problems и столкнулся со следующей проблемой (прошу палками не забивать, я OCaml практически не трогал до этого момента): open OUnit2 let create_...
К|/|pи/\/\ 6е3yглbIи
2
Except the wealthiest, people that buy crypto want to "cash out" at the end of the day, one way or another. Converting to fiat is craziness, converting to BTC is unwise. Hold ...
Erdelanax
2
Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Hello guys, hope you can help me with a quick question. I've staked some ZIL using Atomic Wallet some while ago and wanted to claim my rewards and unstake it. Atomic Wallet sa...
Martin | #bornbrave
14
Карта сайта