Why is AES function returning different value?

user3081123

Why is AES with same secret phrase and message returns different values each time? Let's say we have a same salt for each PBKDF2 functions( I know it's bad, it's just for an example). Let's say we are entering same passphrase each time.

var salt = "5J07c/a7+2bf=15$56aQc75Ub55=60&0";
console.log(req.body.password);
console.log(salt);
var PBKDF2hash = crypto.PBKDF2(req.body.password, salt, { keySize: 256/32 });
console.log(PBKDF2hash.toString());
var AEScipher = crypto.AES.encrypt(req.body.password, PBKDF2hash);
console.log(AEScipher.toString());

In this case we receive same PBKDF2hash (as expected), but any time AES provides different chipher.

zz
5J07c/a7+2bf=15$56aQc75Ub55=60&0
3949676666ed318087a52896be98dc80b0cad99f4b662d48565283f71a2ace80
U2FsdGVkX19O1pqgL+V6Chk8NdiJQhf15N1uEfYXgxw=
zz
5J07c/a7+2bf=15$56aQc75Ub55=60&0
3949676666ed318087a52896be98dc80b0cad99f4b662d48565283f71a2ace80
U2FsdGVkX1/C7GAmLJvfFAHyOYj7LKZI5278/ZoeA3M=

These answers says the thing is salt is differrent and cbc mode matters. In my case salt is constant and I've switched to other modes. Output is still different each time.

dr jimbob

The initialization vector used in CBC mode is a random block, so each encryption will be different. An IV is sort of like a salt, except when encrypting a message there is no reason to ever specify any specific IV to use (a random IV should always be used). The IV is often put in front of the first block of the encrypted message.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

PHP function not returning value

분류에서Dev

Why MySQL BIT_OR() is returning different value than PHP bitwise operation

분류에서Dev

Why MySQL BIT_OR() is returning different value than PHP bitwise operation

분류에서Dev

Why is diff returning an incorrect value?

분류에서Dev

Returning a value from a recursive function

분류에서Dev

Function not returning the Value of its Key

분류에서Dev

function returning wrong value while executing

분류에서Dev

Returning a value from a function with Alamofire and SwiftyJson

분류에서Dev

mean of non zero elements - why are these two attempt returning different results?

분류에서Dev

Why are print_r and return returning different values?

분류에서Dev

Why the function pointer pointing to different function works than it is defined

분류에서Dev

Why does a void function return a value?

분류에서Dev

Why is my function static variable never different despite being incremented?

분류에서Dev

Why is this not returning an @@ERROR?

분류에서Dev

btrfs: why subvolid is different than value provided to mount?

분류에서Dev

why the value of (n) in big oh notation examples is different?

분류에서Dev

C call a different function based on a given integer value

분류에서Dev

TSQL Table Value Function Parameter different behavior if parameter a variable

분류에서Dev

how to pass a value from a recursive function into an array in a different method

분류에서Dev

Function returning pointer to string

분류에서Dev

Returning Value from Actor

분류에서Dev

AngularJS : service not returning value

분류에서Dev

ArrayList returning null value

분류에서Dev

Returning a value from a Method

분류에서Dev

Returning a value from a Thread?

분류에서Dev

strlen returning wrong value

분류에서Dev

Pointer to function returning function pointer

분류에서Dev

C++ Function supposed to return Long, returning Integer like value instead

분류에서Dev

Different AES implementations don't agree

Related 관련 기사

  1. 1

    PHP function not returning value

  2. 2

    Why MySQL BIT_OR() is returning different value than PHP bitwise operation

  3. 3

    Why MySQL BIT_OR() is returning different value than PHP bitwise operation

  4. 4

    Why is diff returning an incorrect value?

  5. 5

    Returning a value from a recursive function

  6. 6

    Function not returning the Value of its Key

  7. 7

    function returning wrong value while executing

  8. 8

    Returning a value from a function with Alamofire and SwiftyJson

  9. 9

    mean of non zero elements - why are these two attempt returning different results?

  10. 10

    Why are print_r and return returning different values?

  11. 11

    Why the function pointer pointing to different function works than it is defined

  12. 12

    Why does a void function return a value?

  13. 13

    Why is my function static variable never different despite being incremented?

  14. 14

    Why is this not returning an @@ERROR?

  15. 15

    btrfs: why subvolid is different than value provided to mount?

  16. 16

    why the value of (n) in big oh notation examples is different?

  17. 17

    C call a different function based on a given integer value

  18. 18

    TSQL Table Value Function Parameter different behavior if parameter a variable

  19. 19

    how to pass a value from a recursive function into an array in a different method

  20. 20

    Function returning pointer to string

  21. 21

    Returning Value from Actor

  22. 22

    AngularJS : service not returning value

  23. 23

    ArrayList returning null value

  24. 24

    Returning a value from a Method

  25. 25

    Returning a value from a Thread?

  26. 26

    strlen returning wrong value

  27. 27

    Pointer to function returning function pointer

  28. 28

    C++ Function supposed to return Long, returning Integer like value instead

  29. 29

    Different AES implementations don't agree

뜨겁다태그

보관