Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
This is my attempt at making a simple Enigma simulator. I've looked extensively at lots of web pages, but mostly Wikipedia.
I have focused on functionality, so this simulator behaves as a proper Enigma M3/M4. This includes the "double stepping", which was probably unintended in the original device.
const Enigma = require("enigma");
// Initialise a new Enigma object.
const enigma = new Enigma();
// Now "press" a key and show the result
const encodedLetter = enigma.onKey("A");
console.log(`"A" becomes ${encodedLetter}`);
Please note that creating a new Enigma can throw an error if the options are incorrect. Wrapping it in a try
/catch
is probably a good idea.
The default configuration is as follows:
{
"type": 3,
"rotors": [{
"type": "I",
"ringSetting": 1,
"rotorOffset": "A"
}, {
"type": "II",
"ringSetting": 1,
"rotorOffset": "A"
}, {
"type": "III",
"ringSetting": 1,
"rotorOffset": "A"
}],
"reflectorType": "B",
"plugBoard": []
}
This is also available as a JSON file inside the test
directory. The plugBoard configuration is an array of letter combinations, like so: ["AE", "PT", "SH"]. Invalid settings will throw an Error. In real life, only 10 pairs were connected.
The rotors in the array are from LEFT to RIGHT. The type
defines which Enigma you want to use: 3 for M3, 4 for M4. Upon initalisation, the number of rotors will be checked. You need to pass in 3 rotors for an M3 and 4 rotors for an M4. However, independent of that choice, the first rotor in the array is always the LEFT one as seen by the operator.
When you're configuring the M4, the left rotor (first one in the list) can be of type "beta" or "gamma". Any other rotor at this position will throw an Error.
The rotors that are allowed are I - VIII, and cannot use the same rotor twice in a configuration. The reflector type is either B or C. Different reflectors are used for M3 and M4, but this is handled automatically. To make life a little bit easier, you only have to configure B or C.
Enigma([options])
options
- an optional map that describes the settings of the Enigma.
onKey(c)
c
- a character that needs to be encoded. Enforced to be a string with length of 1.
onMessage(msg)
msg
- a message that needs to be encoded. May not be empty, it should have length 1 or greater. It's a convenience function, because Enigma machines didn't have such a feature.
reset()
This resets the Enigma to the initial settings using the configuration passed in through the constructor. It's a convenience function that prevents from having to create another Enigma instance.
FAQs
Simple Enigma M3/M4 simulator.
We found that enigma-sim demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.