Вот код, который я использовал для тестирования. это:
Код Python (с выводом):
Код: Выделить всё
import base64
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
input = b'helloworld'
hkdf = HKDF(
algorithm=hashes.SHA256(),
length=48, # 32 bytes for key + 16 bytes for IV
salt=b'\x00' * 32, # Explicit salt
info=b'',
)
output = hkdf.derive(input)
print(base64.b16encode(output))
# Output: b'E76D8FF8CE3E6FBFA6EBDD3BCE19766940316D2973503BB7B174C3F667EDE0AA65C9A74686D38E5B3FF8411A6E8354A8'
Код: Выделить всё
import crypto from 'crypto';
const input = Buffer.from("helloworld");
const salt = Buffer.alloc(32, 0); // Explicit salt
const output = crypto.hkdfSync('sha256', salt, input, Buffer.alloc(0), 48);
console.log(Buffer.from(output).toString("hex"));
// Output: 10523f4571d67851f2e3549a6071cef99db6cc88619a30e7d0419b38054ef63873409a0dbf4e5f4e66b693af44c3e393
Подробнее здесь: https://stackoverflow.com/questions/792 ... esults-why
Мобильная версия