Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enigma-sim

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enigma-sim - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

README.md~

29

Enigma.js

@@ -102,3 +102,4 @@ const _ = require('underscore');

// For M4, we need the tiny reflector wheels (b/c)
const subType = this.options.type === 3 ? this.options.reflectorType : this.options.reflectorType.toLowerCase();
this.type = this.options.type;
const subType = this.type === 3 ? this.options.reflectorType : this.options.reflectorType.toLowerCase();
const reflectorType = `UKW-${subType}`;

@@ -201,9 +202,31 @@

* Encode an entire message character by character
* @param rotors [optional]
* @param msg
*/
onMessage(msg) {
onMessage(rotors, msg) {
if (!msg) {
msg = rotors;
rotors = null;
}
if (!msg || msg.length < 1) {
throw new EnigmaError('Invalid use of onMessage()');
throw new EnigmaError('Empty message passed to onMessage()');
}
if (rotors) {
if (rotors.length !== this.rotors.length) {
throw new EnigmaError('Wrong number of rotors passed to onMessage()');
}
if (!/^[A-Z]{3,4}$/.exec(rotors)) {
throw new EnigmaError('Invalid rotors settings passed to onMessage()')
}
// Setup the rotor offsets
rotors.split('').reverse().forEach((r, i) => this.rotors[i].setOffset(r));
}
// Be forgiving: turn everything into uppercase, replace ' ' with X,
// remove everything that is not a character A-Z.
msg = msg.toUpperCase().replace(/\s/g, 'X').replace(/[^A-Z]/g, '');
// Simulate key presses for all characters in the message

@@ -210,0 +233,0 @@ return msg.split('').map(x => this.onKey(x)).join('');

{
"name": "enigma-sim",
"version": "0.1.0",
"version": "0.2.0",
"description": "Simple Enigma M3/M4 simulator.",

@@ -9,2 +9,6 @@ "main": "Enigma.js",

},
"repository": {
"type": "git",
"url": "git+https://github.com/Sandyman/enigma.git"
},
"author": "Sander Huijsen <sander.huijsen@gmail.com>",

@@ -11,0 +15,0 @@ "license": "ISC",

2

README.md

@@ -5,3 +5,3 @@ # Enigma simulator

I have focussed 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.
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.

@@ -8,0 +8,0 @@ ### Example

@@ -120,4 +120,15 @@ const autoBind = require('auto-bind');

}
/**
* Set offset for this rotor
* @param offset
*/
setOffset(offset) {
this.rotorOffset = _idx(offset);
if (this.rotorOffset < 0) {
this.rotorOffset = 0;
}
}
}
module.exports = Rotor;

@@ -28,1 +28,4 @@ WETTERVORHERSAGE a

"QB"
SFBWDNJUSEGQOBHKRTAREEZMWKPPRBXOHDROEQGBBGTQVPGVKBVVGBIMHUSZYDAJQIROAXSSSNREHYGGRPISEZBOVMQIEMMZCYSGQDGRERVBILEKXYQIRGIRQNRDNVRXCYYTNJR
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc