aes encryption
This commit is contained in:
@@ -147,6 +147,11 @@ const Login = inject("rootStore") ( observer(
|
||||
<li>
|
||||
<b>Copy</b> the password by just one button click
|
||||
</li>
|
||||
<br />
|
||||
<li>
|
||||
<b>For nerds: </b><a href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard" target="_blank" rel="noopener noreferrer">AES (Rijndael cipher) </a>
|
||||
encrypted with a 128 bits key, 10 rounds and a blocksize of 128 bits. Established by the U.S. NIST in 2001 and approved by the NSA for "top secret" information.
|
||||
</li>
|
||||
</ul>
|
||||
<img alt="" className={this.classes.ninja} src={require('../files/images/ninja.svg')} />
|
||||
</Segment>
|
||||
|
@@ -14,7 +14,7 @@ import { decrypt } from '../../stores/functions/encryption';
|
||||
/*
|
||||
* Component imports
|
||||
*/
|
||||
import New from './New';
|
||||
import New from '../../components/PasswordManager/New';
|
||||
import Headline from '../../components/Headline';
|
||||
|
||||
jss.setup(preset());
|
||||
@@ -289,6 +289,11 @@ const PasswordManager = inject("rootStore") ( observer(
|
||||
<p>
|
||||
<b>I advise you to choose one encryption key and use it for all your passwords in your list.</b> Why? Using the same key makes decrypting easier for you because <b>all</b> entries are being decrypted correctly at the same time by using one single key.
|
||||
</p>
|
||||
<hr />
|
||||
<p>
|
||||
<b>For nerds: </b><a href="https://en.wikipedia.org/wiki/Advanced_Encryption_Standard" target="_blank" rel="noopener noreferrer">AES (Rijndael cipher) </a>
|
||||
encrypted with a 128 bits key, 10 rounds and a blocksize of 128 bits. Established by the U.S. NIST in 2001 and approved by the NSA for "top secret" information.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@@ -1,13 +1,24 @@
|
||||
function norm_to_ascii(string){return unescape(encodeURIComponent(string))};
|
||||
function norm_to_unicode(string){return decodeURIComponent(escape(string))};
|
||||
function crypt_sym(string,k){return String.fromCharCode.apply(undefined,string.split("").map(function(c){return c.charCodeAt(0)^(k||13)}))};
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
export function encrypt(string, key) {
|
||||
//Encrypt a string
|
||||
return btoa(crypt_sym(norm_to_ascii(string), key));
|
||||
return CryptoJS.AES.encrypt(string, key).toString();
|
||||
}
|
||||
|
||||
export function decrypt(string, key) {
|
||||
export function decrypt(ciphertext, key) {
|
||||
//Decrypt a string
|
||||
return crypt_sym(norm_to_unicode(atob(string)), key);
|
||||
var bytes = CryptoJS.AES.decrypt(ciphertext, key);
|
||||
var originalText;
|
||||
|
||||
try {
|
||||
originalText = bytes.toString(CryptoJS.enc.Utf8);
|
||||
|
||||
if(originalText === '') {
|
||||
originalText = CryptoJS.HMACMD5(key + ciphertext).toString(CryptoJS.enc.Hex).substring(0, 15);
|
||||
}
|
||||
} catch(ex) {
|
||||
originalText = CryptoJS.SHA256(key + ciphertext).toString(CryptoJS.enc.Hex).substring(0, 15);
|
||||
}
|
||||
|
||||
return originalText;
|
||||
}
|
Reference in New Issue
Block a user