npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

she_decrypt

v1.2.5

Published

Pure JavaScript implementation for deciphering SHE arguments (M1, M2, etc)

Downloads

19

Readme

SHE_decrypt

[TOC]

Pure JavaScript implem for SHE commands args deciphering of MAC key provisionning CAN/Ethernet frames. This implementation relies on the MiyaguchiPreneel compression function implemented in the (also pure) JavaScript implementation of the miyaguchipreneel npm module.

Install

npm install

Usage

SHE_decrypt exposes an API using node:Buffer. It allows really straigth forward CAN/Eth frame manipulation.

   const she = require('she_decrypt');

   var frameBuf = Buffer.from(<get your can frames, a way or another>, 'hex');
   var frameKey = Buffer.from(<get your key the same way or another>, 'hex);
   
   var she_decrypt = new she();
   
   var decM2 = she_decrypt.decrypt_M2(frameBuf, frameKey);
   
   var cid  = she_decrypt.getCID(decM2);
   var fid  = she_decrypt.getFID(decM2);
   var key  = she_decrypt.getKEY(decM2);
   var chan = she_decrypt.getChannel(frameBuf);
she_decrypt: usage: she_decrypt [OPTIONS] [ARGUMENTS]
                    This script allows to parse CAN frames trace log file and extract from
                    it the provisionning UDS frames, then extracting the SHE messages from
                    it.
                    OPTIONS:
                       [-v|--verbose=[<integer>]]  be  more  verbose  when  running.
                       [-h|--help]                 display  this  help  message.
                       [-c|--cid]                  display the CID of the SHE message.
                       [-f|--fid]                  display the FID of the SHE message.
                       [-C|--channel]              display the channel of the SHE message.

                    ARGUMENTS:
                       [-m|--msg=[<SHEmsg>]]       SHE  message to process and decipher.
                       [-M|--msg-file=[<SHEfile>]] file  containing the  SHE message to
                                                   decipher. If filename provided is set to
                                                   '-' the  STDIN  is used for reading the
                                                   SHE  message.  This is  the  default.
                       [-K|--Kmaster=[<key>]]      Kmaster to use to decipher the SHE msg.
                                                   By default  the Kmaster key has value:
                                                     0153F7000099ED9F320451AA8A7D9707

Copyright © 2023 RENAULT GROUP / Rémi COHEN SCALI <[email protected]>
# SHE 1 Prov (M1/M2/M3) EVC
00000000000000000000000000000011e9550f568a7cb43c8e82fc97f09ea71d63ca54eeaff2963a95fa68d64833950a17ad655772b0c644632c855c0da059aa
00000000000000000000000000000041f2d9f8203a15339a63f8d3a649c687b397f25c4d4c84c3800daa5fc684e081979469a496ea1908b9a643e036f50176b6
0000000000000000000000000000001114c192927bf31676d3d63a2575b5f84e8a8be9da158e3711b4e602ba068af1fe4ae3eff29ec6c613cb03c4fd42680750
00000000000000000000000000000041d0712612d44d059fd935ade25c1425dd8f6ff806fb9977181489902088883a5d7283f224c7e7df8f6c5a906ba932131a
00000000000000000000000000000041d0712612d44d059fd935ade25c1425dd8f6ff806fb9977181489902088883a5d7283f224c7e7df8f6c5a906ba932131a
# SHE 1 Prov (M1/M2/M3) EVC
00000000000000000000000000000011e9550f568a7cb44c8e82fc97f09ea71d63ca54eeaff2963a95fa68d64833950a17ad655772b0c644632c855c0da059aa
00000000000000000000000000000041f2d9f8203a1533aa63f8d3a649c687b397f25c4d4c84c3800daa5fc684e081979469a496ea1908b9a643e036f50176b6
a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/all_mac/SHE_decrypt$ cat tests/msg.txt | ./bin/she_decrypt -cf
CID = 0x2000085
FID = 0
Kmaster: 0f90af60245edfd794c4e606202371ae
CID = 0x2000087
FID = 2
Kmac: ed28a6fbae79f25c17112917711a54ad

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/all_mac/SHE_decrypt$ cat tests/msg2.txt | ./bin/she_decrypt -cf
CID = 0x200001e
FID = 0
Kmaster: c85c499d7ed56116302371372834c3ae
CID = 0x2000020
FID = 2
Kmac: 99900b0679387f91ea4db0119e07979a

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/all_mac/SHE_decrypt$ cat tests/msg3.txt | ./bin/she_decrypt -cf
she_decrypt: error: SHE message for Kmac was not correctly deciphered !

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/all_mac/SHE_decrypt$ cat tests/msg_error.txt | ./bin/she_decrypt -cf
she_decrypt: error: SHE message for Kmaster was not correctly deciphered !
she_decrypt: error: SHE message for Kmac was not correctly deciphered !

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/all_mac/SHE_decrypt$

Here is the deciphering of the examples SHE msgs generated in the README.md of SHE_encrypt module. The messages were generated with the following commands:

./bin/generate_she.js -k A123456789B123456789C123456789D1 -m 1F987654321E987654321D987654321C -c 0x2000001
./bin/generate_she.js -K -k 123456789B123456789C123456789D12 -m A123456789B123456789C123456789D1 -c 0x2000002 -C 1
./bin/generate_she.js -K -k 23456789B123456789C123456789D123 -m A123456789B123456789C123456789D1 -c 0x2000003 -C 2
./bin/generate_she.js -K -k 3456789B123456789C123456789D1234 -m A123456789B123456789C123456789D1 -c 0x2000004 -C 3
./bin/generate_she.js -K -k 456789B123456789C123456789D12345 -m A123456789B123456789C123456789D1 -c 0x2000005 -C 4
./bin/generate_she.js -K -k 56789B123456789C123456789D123456 -m A123456789B123456789C123456789D1 -c 0x2000006 -C 5

and produced the following SHE messages:

00000000000000000000000000000011c44f5059d23ce5fd079a19cc8b1b5804aacc41183dc38b140c392f16a21c2a92fff0a3eb96f502d96e64edac0bc338a2
00000000000000000000000000000041eeb96ef0669d947bdb5986718728728067125e06117dc0f61318952c008f7e96546a16ca23f1e3b890c74cb7a57840d4
00000000000000000000000000000051d719bb4cd7ee7466235668e914c8da40db467e3ab4738cbc0b3e9b4f2e32605bce732465323c03b7df4380776c05f6e4
00000000000000000000000000000061721fddd669375ee9a4102c756470f45718e8a40ff19995324a33af0b1ed5959de73a7ceffb2f30de4f7a94a68826e5b9
00000000000000000000000000000071d22671dc00fcc446d965a621af39c29aac811e52c989b47307377b9eaa6242dda137c4c9c0fdc04daa949bd62c5230a9
0000000000000000000000000000008114d7f1abf977ced2a85d1bfbfae1e9f22eea974476f58cec023ca846017df276a5cd817929cdec2e64ed3dc4c7e4e974

The commands for deciphering these messages are shown here after:

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_decrypt$ echo "00000000000000000000000000000011c44f5059d23ce5fd079a19cc8b1b5804aacc41183dc38b140c392f16a21c2a92fff0a3eb96f502d96e64edac0bc338a2" | ./bin/she_decrypt -cf -K 1F987654321E987654321D987654321C
CID = 0x2000001
FID = 0
Kmaster: a123456789b123456789c123456789d1

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_decrypt$ echo "00000000000000000000000000000041eeb96ef0669d947bdb5986718728728067125e06117dc0f61318952c008f7e96546a16ca23f1e3b890c74cb7a57840d4" | ./bin/she_decrypt -cfC -K A123456789B123456789C123456789D1
CID = 0x2000002
FID = 2
Channel = 1
Kmac: 123456789b123456789c123456789d12

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_decrypt$ echo "00000000000000000000000000000051d719bb4cd7ee7466235668e914c8da40db467e3ab4738cbc0b3e9b4f2e32605bce732465323c03b7df4380776c05f6e4" | ./bin/she_decrypt -cfC -K A123456789B123456789C123456789D1
CID = 0x2000003
FID = 2
Channel = 2
Kmac: 23456789b123456789c123456789d123

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_decrypt$ echo "00000000000000000000000000000061721fddd669375ee9a4102c756470f45718e8a40ff19995324a33af0b1ed5959de73a7ceffb2f30de4f7a94a68826e5b9" | ./bin/she_decrypt -cfC -K A123456789B123456789C123456789D1
CID = 0x2000004
FID = 2
Channel = 3
Kmac: 3456789b123456789c123456789d1234

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_decrypt$ echo "00000000000000000000000000000071d22671dc00fcc446d965a621af39c29aac811e52c989b47307377b9eaa6242dda137c4c9c0fdc04daa949bd62c5230a9" | ./bin/she_decrypt -cfC -K A123456789B123456789C123456789D1
CID = 0x2000005
FID = 2
Channel = 4
Kmac: 456789b123456789c123456789d12345

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_decrypt$ echo "0000000000000000000000000000008114d7f1abf977ced2a85d1bfbfae1e9f22eea974476f58cec023ca846017df276a5cd817929cdec2e64ed3dc4c7e4e974" | ./bin/she_decrypt -cfC -K A123456789B123456789C123456789D1
CID = 0x2000006
FID = 2
Channel = 5
Kmac: 56789b123456789c123456789d123456

Another way of deciphering all these messages (contained in the tests/msgsw500.txt file) is through a file containing all messages. Then use:

a047461@FRUH112777 MINGW64 ~/OneDrive - Alliance/Sources/MAC/export/repos/all_mac/SHE_decrypt$ cat tests/msgsw500.txt | ./bin/she_decrypt -cfC -K 1F987654321E987654321D987654321C
CID = 0x2000001
FID = 0
Kmaster: a123456789b123456789c123456789d1
CID = 0x2000002
FID = 2
Channel = 1
Kmac: 123456789b123456789c123456789d12
CID = 0x2000003
FID = 2
Channel = 2
Kmac: 23456789b123456789c123456789d123
CID = 0x2000004
FID = 2
Channel = 3
Kmac: 3456789b123456789c123456789d1234
CID = 0x2000005
FID = 2
Channel = 4
Kmac: 456789b123456789c123456789d12345
CID = 0x2000006
FID = 2
Channel = 5
Kmac: 56789b123456789c123456789d123456

# or by providing the file on the command line:
# ./bin/she_decrypt -cfC -K 1F987654321E987654321D987654321C -M tests/msgsw500.txt

The tool find a Kmaster as the first message, decipher it and get the key for deciphering all others. Each time it find a Kmaster it try to use it for further messages.

For testing the SHE_decrypt.js component and script, use

rcoscali@ubuntu-lx-23-10:~/Sources/she_decrypt$ npm test

> [email protected] test
> jest --colors --json > results.json

 PASS  ./test.js
 PASS  tests/nominal.test.ts

Test Suites: 2 passed, 2 total
Tests:       31 passed, 31 total
Snapshots:   0 total
Time:        2.13 s, estimated 3 s
Ran all test suites.
rcoscali@ubuntu-lx-23-10:~/Sources/she_decrypt$