@@ -5,7 +5,7 @@ class lesspassController { | |||
constructor() { | |||
this.lowercase = true; | |||
this.uppercase = true; | |||
this.number = true; | |||
this.numbers = true; | |||
this.symbols = true; | |||
} | |||
displayHelp(){ | |||
@@ -14,21 +14,21 @@ class lesspassController { | |||
createPassword() { | |||
var passwordTypes = []; | |||
if (this.lowercase) { | |||
passwordTypes.push('lowercase') | |||
passwordTypes.push('lowercase'); | |||
} | |||
if (this.uppercase) { | |||
passwordTypes.push('uppercase') | |||
passwordTypes.push('uppercase'); | |||
} | |||
if (this.number) { | |||
passwordTypes.push('number') | |||
if (this.numbers) { | |||
passwordTypes.push('numbers'); | |||
} | |||
if (this.symbols) { | |||
passwordTypes.push('symbols') | |||
passwordTypes.push('symbols'); | |||
} | |||
var site_information = { | |||
'site_name': this.site, | |||
'password_length': 12, | |||
'password_type': passwordTypes, | |||
'password_types': passwordTypes, | |||
'counter': 1 | |||
}; | |||
@@ -1,15 +1,15 @@ | |||
import crypto from 'crypto'; | |||
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); | |||
} | |||
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 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); | |||
} | |||
@@ -26,7 +26,7 @@ export class lesspass { | |||
var passwordTypesInfo = { | |||
lowercase: {value: 'vc', order: 1}, | |||
uppercase: {value: 'VC', order: 2}, | |||
number: {value: 'n', order: 3}, | |||
numbers: {value: 'n', order: 3}, | |||
symbols: {value: 's', order: 4}, | |||
strong: {value: 'Cvcvns', order: 5} | |||
}; | |||
@@ -24,7 +24,8 @@ | |||
} | |||
#headlines { | |||
padding: 50px 0; | |||
padding-top: 50px; | |||
padding-bottom: 50px; | |||
} | |||
</style> | |||
<script src="js/jquery-1.9.1.min.js"></script> | |||
@@ -37,7 +38,7 @@ | |||
<div id="header"> | |||
<div class="container text-center"> | |||
<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"> | |||
</a> | |||
</div> | |||
@@ -137,7 +138,7 @@ | |||
<div class="col-md-2"> | |||
<div class="checkbox"> | |||
<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) | |||
</label> | |||
</div> | |||
@@ -8,7 +8,7 @@ describe('lesspass', ()=> { | |||
var site_information = { | |||
'site_name': 'facebook', | |||
'password_length': 12, | |||
'password_type': ['strong'], | |||
'password_types': ['strong'], | |||
'counter': 1 | |||
}; | |||
assert.equal('Vexu8[Syce4&', lesspass.create_password(master_password, site_information)); | |||
@@ -54,12 +54,12 @@ describe('lesspass', ()=> { | |||
it('should get template from password type', ()=> { | |||
assert.equal('vc', lesspass._getTemplate(['lowercase'])); | |||
assert.equal('VC', lesspass._getTemplate(['uppercase'])); | |||
assert.equal('n', lesspass._getTemplate(['number'])); | |||
assert.equal('n', lesspass._getTemplate(['numbers'])); | |||
assert.equal('s', lesspass._getTemplate(['symbols'])); | |||
}); | |||
it('should concatenate template if two password types', ()=> { | |||
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', ()=> { | |||
assert.equal( | |||