瀏覽代碼

change api for password types

pull/44/head
Guillaume Vincent 9 年之前
父節點
當前提交
7b2f03b0d4
共有 4 個文件被更改,包括 20 次插入19 次删除
  1. +7
    -7
      app/app.js
  2. +6
    -6
      app/lesspass.js
  3. +4
    -3
      static/index.html
  4. +3
    -3
      tests/lesspass.tests.js

+ 7
- 7
app/app.js 查看文件

@@ -5,7 +5,7 @@ class lesspassController {
constructor() { constructor() {
this.lowercase = true; this.lowercase = true;
this.uppercase = true; this.uppercase = true;
this.number = true;
this.numbers = true;
this.symbols = true; this.symbols = true;
} }
displayHelp(){ displayHelp(){
@@ -14,21 +14,21 @@ class lesspassController {
createPassword() { createPassword() {
var passwordTypes = []; var passwordTypes = [];
if (this.lowercase) { if (this.lowercase) {
passwordTypes.push('lowercase')
passwordTypes.push('lowercase');
} }
if (this.uppercase) { if (this.uppercase) {
passwordTypes.push('uppercase')
passwordTypes.push('uppercase');
} }
if (this.number) {
passwordTypes.push('number')
if (this.numbers) {
passwordTypes.push('numbers');
} }
if (this.symbols) { if (this.symbols) {
passwordTypes.push('symbols')
passwordTypes.push('symbols');
} }
var site_information = { var site_information = {
'site_name': this.site, 'site_name': this.site,
'password_length': 12, 'password_length': 12,
'password_type': passwordTypes,
'password_types': passwordTypes,
'counter': 1 'counter': 1
}; };




+ 6
- 6
app/lesspass.js 查看文件

@@ -1,15 +1,15 @@
import crypto from 'crypto'; import crypto from 'crypto';
export class lesspass { export class lesspass {
static create_password(master_password, site_information) {
var hash = this._create_hash(master_password, site_information);
var template = this._getTemplate(site_information.password_type);
static create_password(masterPassword, siteInformation) {
var hash = this._create_hash(masterPassword, siteInformation);
var template = this._getTemplate(siteInformation.password_types);
return this._encode(hash, template); return this._encode(hash, template);
} }
static _create_hash(master_password, {site_name, password_length=12, counter=1}) {
static _create_hash(masterPassword, {site_name, password_length=12, counter=1}) {
var salt = site_name + counter.toString(); var salt = site_name + counter.toString();
var password = crypto.createHmac('sha256', master_password).update(salt).digest('hex');
var password = crypto.createHmac('sha256', masterPassword).update(salt).digest('hex');
return password.substring(0, password_length); return password.substring(0, password_length);
} }
@@ -26,7 +26,7 @@ export class lesspass {
var passwordTypesInfo = { var passwordTypesInfo = {
lowercase: {value: 'vc', order: 1}, lowercase: {value: 'vc', order: 1},
uppercase: {value: 'VC', order: 2}, uppercase: {value: 'VC', order: 2},
number: {value: 'n', order: 3},
numbers: {value: 'n', order: 3},
symbols: {value: 's', order: 4}, symbols: {value: 's', order: 4},
strong: {value: 'Cvcvns', order: 5} strong: {value: 'Cvcvns', order: 5}
}; };


+ 4
- 3
static/index.html 查看文件

@@ -24,7 +24,8 @@
} }


#headlines { #headlines {
padding: 50px 0;
padding-top: 50px;
padding-bottom: 50px;
} }
</style> </style>
<script src="js/jquery-1.9.1.min.js"></script> <script src="js/jquery-1.9.1.min.js"></script>
@@ -37,7 +38,7 @@
<div id="header"> <div id="header">
<div class="container text-center"> <div class="container text-center">
<div id="logo"> <div id="logo">
<a href="https://lesspass.com" id="lesspass-logo-link">
<a href="http://lesspass.com" id="lesspass-logo-link">
<img alt="lesspass" id="lesspass-logo" src="images/favicon.svg"> <img alt="lesspass" id="lesspass-logo" src="images/favicon.svg">
</a> </a>
</div> </div>
@@ -137,7 +138,7 @@
<div class="col-md-2"> <div class="col-md-2">
<div class="checkbox"> <div class="checkbox">
<label> <label>
<input type="checkbox" ng-model="lesspass.number" ng-checked="lesspass.number">
<input type="checkbox" ng-model="lesspass.numbers" ng-checked="lesspass.numbers">
nombres (0-9) nombres (0-9)
</label> </label>
</div> </div>


+ 3
- 3
tests/lesspass.tests.js 查看文件

@@ -8,7 +8,7 @@ describe('lesspass', ()=> {
var site_information = { var site_information = {
'site_name': 'facebook', 'site_name': 'facebook',
'password_length': 12, 'password_length': 12,
'password_type': ['strong'],
'password_types': ['strong'],
'counter': 1 'counter': 1
}; };
assert.equal('Vexu8[Syce4&', lesspass.create_password(master_password, site_information)); assert.equal('Vexu8[Syce4&', lesspass.create_password(master_password, site_information));
@@ -54,12 +54,12 @@ describe('lesspass', ()=> {
it('should get template from password type', ()=> { it('should get template from password type', ()=> {
assert.equal('vc', lesspass._getTemplate(['lowercase'])); assert.equal('vc', lesspass._getTemplate(['lowercase']));
assert.equal('VC', lesspass._getTemplate(['uppercase'])); assert.equal('VC', lesspass._getTemplate(['uppercase']));
assert.equal('n', lesspass._getTemplate(['number']));
assert.equal('n', lesspass._getTemplate(['numbers']));
assert.equal('s', lesspass._getTemplate(['symbols'])); assert.equal('s', lesspass._getTemplate(['symbols']));
}); });
it('should concatenate template if two password types', ()=> { it('should concatenate template if two password types', ()=> {
assert.equal('vcVC', lesspass._getTemplate(['lowercase', 'uppercase'])); assert.equal('vcVC', lesspass._getTemplate(['lowercase', 'uppercase']));
assert.equal('vcns', lesspass._getTemplate(['lowercase', 'number', 'symbols']));
assert.equal('vcns', lesspass._getTemplate(['lowercase', 'numbers', 'symbols']));
}); });
it('should not care about order of type in password types', ()=> { it('should not care about order of type in password types', ()=> {
assert.equal( assert.equal(


Loading…
取消
儲存