0

I have a C# application required to calculate token same as JavaScript below:

key = CryptoJS.enc.Hex.parse("436574536f667445454d537973576562");
iv = CryptoJS.enc.Hex.parse("1934577290ABCDEF1264147890ACAE45");
text ={userID: 0,tokenTime:'2017-05-06 19:20:22'};
text=JSON.stringify(text);
token=CryptoJS.AES.encrypt(text,key,{iv:iv}).toString();

token=9L9qY0fmi3Riysac3YbIciIIJFisPZZC3uBxjriVH1OyARL2ZQ/HVO941/Tod2PT

(JavaScript can not be change)

But,I am confuse by what is include in string "token"?

only ciphertext or whole result of encryption in string?

And,how to convert format of key and iv for CryptoJS to a format which accepted by C#(RijndaelManaged or AesCryptoServiceProvider)?

Most of the question and answer using "CryptoJS.enc.utf8.parse",so I try to convert key and iv from hex to utf-8 ,but only key can be converted.

  • 1) token is the ciphertext encoded as base64. 2) To convert key and iv in C# you would retrieve a byte array from the hex strings as illustrated here http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa – Alex K. May 22 '17 at 09:28
  • thanks,it works.I read that before i just don't know why i didn't try it. –  May 22 '17 at 12:37

0 Answers0