Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Siriusq committed Mar 11, 2023
1 parent 63dab5c commit 3db659e
Show file tree
Hide file tree
Showing 20 changed files with 1,065 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# Fidelius
基于Argon2加密算法的密码生成器 / Password generator based on Argon2 algorithm
Fidelius 是一款基于 [Argon2](https://en.wikipedia.org/wiki/Argon2) 加密算法的密码生成器。它以记忆密码为主密码P,以域名区分标识与生成时间为哈希盐S,将二者进行多次哈希运算迭代,再使用 [SeekPassword](https://github.com/Wsine/seekpassword) 的算法对结果进行进一步处理,最终得到用户需要的密码。

## 预览
[Live Demo](https://siriusq.top/Fidelius/)
![](https://github.com/Siriusq/Fidelius/blob/master/preview.png)

## 特性
- 基于 Argon2 算法, Argon2 算法曾在 2015 年获得 Password Hashing Competition 冠军,能够有效抵御基于 GPU 的暴力破解
- 默认使用 Argon2 的推荐参数,用户也可以自行修改相关参数
- 可在哈希盐中加入密码生成日期,方便日后定期修改密码
- 可自定义密码中使用的特殊符号
- 所有运算均在本地运行,代码开源

## 引用/参考
- [alexrintt/argon2](https://github.com/alexrintt/argon2)
- [mrjooz/password-generator](https://github.com/mrjooz/password-generator/tree/master)
- [Wsine/seekpassword](https://github.com/Wsine/seekpassword)
- [EYHN/PasswordQualityCalculator](https://github.com/EYHN/PasswordQualityCalculator)
- [zenorocha/clipboard.js](https://github.com/zenorocha/clipboard.js)
14 changes: 14 additions & 0 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions css/loading.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.spinner-fullpage{
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: all 0.3s ease-in-out;
animation: fadeIn 0.3s;
}

@keyframes fadeIn {
from {opacity: 0;}
to {opacity: 1;}
}

.spinner-border{
width: 6rem;
height: 6rem;
}
1 change: 1 addition & 0 deletions css/loading.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added favicon.ico
Binary file not shown.
309 changes: 309 additions & 0 deletions index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/dist/argon2-bundled.min.js

Large diffs are not rendered by default.

Binary file added js/dist/argon2-simd.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions js/dist/argon2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added js/dist/argon2.wasm
Binary file not shown.
92 changes: 92 additions & 0 deletions js/fidelius.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
importScripts('./lib/argon2.min.js');

var res;
onmessage = function(event){
var memoryCodeValue = event.data[0];
var saltValue = event.data[1];
var hashLenValue = event.data[2];
var iterationValue = event.data[3];
var memoryUsageValue = event.data[4];
var parallelismValue = event.data[5];
var pwdLengthValue = event.data[6];
var containSymbolsValue = event.data[7];
var containUppercaseValue = event.data[8];
var punctuation = event.data[9];

argon2.hash({
pass: memoryCodeValue,
salt: saltValue,
hashLen: hashLenValue || 64,
time: iterationValue || 3,
mem: memoryUsageValue || 65536,
parallelism: parallelismValue || 1,
type: argon2.ArgonType.Argon2id
})
.then(function (h) {
var hashRes = h.hashHex;
var pwdOutputLength = pwdLengthValue || 16;
var res = seekPassword(hashRes, pwdOutputLength, containSymbolsValue, containUppercaseValue,punctuation);
this.postMessage(res);
})
.catch(e => {
console.log(JSON.stringify({ message: e.message, code: e.code }, null, 2));
})


}

/**
* seek password https://github.com/Wsine/seekpassword
* 生成密码
* @param {sha512加密后字符串} hash
* @param {输出密码长度} length
* @param {是否使用标点} rule_of_punctuation
* @param {是否区分大小写} rule_of_letter
*/
function seekPassword(hash, length, rule_of_punctuation, rule_of_letter, punctuation) {
// 生成字符表
var lower = "abcdefghijklmnopqrstuvwxyz".split("");
var upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
var number = "0123456789".split("");

var alphabet = lower.concat(number);
if (rule_of_punctuation) {
alphabet = alphabet.concat(punctuation);
}
if (rule_of_letter) {
alphabet = alphabet.concat(upper);
}

// 生成密码
// 从0开始截取长度为length的字符串,直到满足密码复杂度为止
for (var i = 0; i <= hash.length - length; ++i) {
var sub_hash = hash.slice(i, i + parseInt(length)).split("");
var count = 0;
var map_index = sub_hash.map(function (c) {
count = (count + c.charCodeAt()) % alphabet.length;
return count;
});
var sk_pwd = map_index.map(function (k) {
return alphabet[k];
});

// 验证密码
var matched = [false, false, false, false];
sk_pwd.forEach(function (e) {
matched[0] = matched[0] || lower.includes(e);
matched[1] = matched[1] || upper.includes(e);
matched[2] = matched[2] || number.includes(e);
matched[3] = matched[3] || punctuation.includes(e);
});
if (!rule_of_letter) {
matched[1] = true;
}
if (!rule_of_punctuation) {
matched[3] = true;
}
if (!matched.includes(false)) {
return sk_pwd.join("");
}
}
return "Error!";
}
Loading

0 comments on commit 3db659e

Please sign in to comment.