Decrypt .Net cookie in nodejs

巧了我就是萌 提交于 2019-12-03 15:51:09

You can see the source code of Encryp and Decrypt here with all the different possibilities (Framework20SP1, Framework20SP2, etc)

https://github.com/Microsoft/referencesource/blob/master/System.Web/Security/FormsAuthentication.cs

It took me hours to read that code, but once you got it, it's possible to write a simple code just for your specific encryption settings.

A key is not a String, take a look at the method fromCharCode():

The fromCharCode() method converts Unicode values into characters.

This means that any hexadecimal is converted to a textual character, while createDecipheriv() method specifies that:

key and iv must be 'binary' encoded strings or buffers.

Note that this is just one of the issues that may be present, I haven't had time to run the code (yet).

Your problem is probably a failure in automatic padding, turned on by default. You want to turn this off, by adding:

c.setAutoPadding(false);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!