Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 841abfb

Browse files
high security strings
1 parent 62645dd commit 841abfb

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

‎high-security-strings.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
3+
const fs = require('fs');
4+
5+
process.stdin.resume();
6+
process.stdin.setEncoding('utf-8');
7+
8+
let inputString = '';
9+
let currentLine = 0;
10+
11+
process.stdin.on('data', function(inputStdin) {
12+
inputString += inputStdin;
13+
});
14+
15+
process.stdin.on('end', function() {
16+
inputString = inputString.split('\n');
17+
18+
main();
19+
});
20+
21+
function readLine() {
22+
return inputString[currentLine++];
23+
}
24+
25+
function getStrength(password, weight_a) {
26+
password = password.toLowerCase();
27+
let c = 0;
28+
for(let i in password){
29+
let value = (password[i].charCodeAt() - 97) + weight_a;
30+
c+= (value <=25) ? value : (value - 26);
31+
}
32+
return c;
33+
}
34+
35+
function main() {
36+
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
37+
38+
const password = readLine();
39+
40+
const weight_a = parseInt(readLine().trim(), 10);
41+
42+
const strength = getStrength(password, weight_a);
43+
44+
ws.write(strength + '\n');
45+
46+
ws.end();
47+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /