Add aes-cbc encryption; add config repo based on shared_preferences

This commit is contained in:
mitchell 2019-07-16 02:14:54 -04:00
parent 80f9705b19
commit 67744527cc
15 changed files with 254 additions and 154 deletions

View file

@ -58,8 +58,10 @@ class _ConfigState extends State<Config> {
: CupertinoNavigationBar(
trailing: GestureDetector(
onTap: _buildResetAllHandler(context),
child: Text('Reset App',
style: TextStyle(color: CupertinoColors.destructiveRed)),
child: Text(
'Reset',
style: TextStyle(color: CupertinoColors.destructiveRed),
),
),
),
child: Container(

View file

@ -30,8 +30,9 @@ class Credentials extends StatelessWidget {
children: [
Text('Decrypting credential...'),
Container(
margin: EdgeInsets.only(top: 10),
child: CupertinoActivityIndicator()),
margin: EdgeInsets.only(top: 10),
child: CupertinoActivityIndicator(),
),
],
)),
);
@ -44,12 +45,18 @@ class Credentials extends StatelessWidget {
final credential = await client.get(id);
credential.password = crypto.decryptPassword(
password, await privateKey, credential.password);
credential.password = crypto.decrypt(
credential.password,
password,
await privateKey,
);
if (credential.otpSecret != null && credential.otpSecret != '') {
credential.otpSecret = crypto.decryptPassword(
password, await privateKey, credential.otpSecret);
if (credential.otpSecret.isNotEmpty) {
credential.otpSecret = crypto.decrypt(
credential.otpSecret,
password,
await privateKey,
);
}
Navigator.of(context)

View file

@ -92,6 +92,7 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
const checkPeriod = 30;
return Timer(Duration(seconds: checkPeriod), () {
_config.reset();
Navigator.of(context)
.pushNamedAndRemoveUntil('/', ModalRoute.withName('/home'));
});
@ -127,7 +128,11 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
}
GestureTapCallback _makeLockOnTapHandler(BuildContext context) {
return () => Navigator.of(context).pushReplacementNamed('/');
return () {
_config.reset();
Navigator.of(context)
.pushNamedAndRemoveUntil('/', ModalRoute.withName('/home'));
};
}
GestureTapCallback _makeConfigOnTapHandler(BuildContext context) {