From 76554e48c38bd2eb60e567918d1d62d3f2a58871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Sun, 14 Aug 2022 23:04:15 +0800 Subject: [PATCH] refactor: only handle error if security command not found --- internal/decrypter/decrypter.go | 7 +++---- internal/decrypter/decrypter_darwin.go | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/decrypter/decrypter.go b/internal/decrypter/decrypter.go index 97484c5..415d681 100644 --- a/internal/decrypter/decrypter.go +++ b/internal/decrypter/decrypter.go @@ -14,10 +14,9 @@ import ( ) var ( - errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal") - errPasswordIsEmpty = errors.New("password is empty") - errDecodeASN1Failed = errors.New("decode ASN1 data failed") - errEncryptedLength = errors.New("length of encrypted password less than block size") + errPasswordIsEmpty = errors.New("password is empty") + errDecodeASN1Failed = errors.New("decode ASN1 data failed") + errEncryptedLength = errors.New("length of encrypted password less than block size") ) type ASN1PBE interface { diff --git a/internal/decrypter/decrypter_darwin.go b/internal/decrypter/decrypter_darwin.go index 63ed643..78c874d 100644 --- a/internal/decrypter/decrypter_darwin.go +++ b/internal/decrypter/decrypter_darwin.go @@ -1,5 +1,9 @@ package decrypter +var ( + errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal") +) + func Chromium(key, encryptPass []byte) ([]byte, error) { if len(encryptPass) <= 3 { return nil, errPasswordIsEmpty