Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsook committed Apr 26, 2021
0 parents commit eaced01
Show file tree
Hide file tree
Showing 115 changed files with 5,959 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

android/app/.cxx
10 changes: 10 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 4d7946a68d26794349189cf21b3f68cc6fe61dcb
channel: stable

project_type: app
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Clarence K.C. Ho

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
![image](https://user-images.githubusercontent.com/13360325/116012081-3924ca80-a5dd-11eb-89ab-9c8543302d7b.png)

# AndSafe

AndSafe is an Android app that encrypts plain text notes. With version 3, AndSafe3 is re-implemented with Flutter and is now open source.

## FAQ
**I can't remember my password. Can you help me?**

Sorry. There is no backdoor to recover lost passwords.

**How to backup my notes?**

AndSafe has no netowork function and hence it won't sync anything to cloud. You are encouraged to backup your notes off your phone regularly. Use the *Export notes* function to backup all notes into a file. Then copy the file to your computer as a backup.

Note that although exported notes are in encrypted form, you should still safeguard the backup file.

**Where are my exported notes?**

For AndSafe v2, notes are export to the folder *AndroidSafeExports* under your internal storage of your phone. For AndSafe3, it is under the app folder itself, e.g. */storage/emulated/0/Android/data/net.clarenceho.andsafe3/files/Documents*.

Note that for AndSafe3, if you uninstall the app, you will also delete all exported files.

**I used previous version of AndSafe. Can I import my notes into AndSafe3?**

AndSafe3 can import notes from AndSafe version 2 but not the other way around. Just export your notes in AndSafe, then open AndSafe3 and use the import function.

**The search function isn't working**

The full-text search can only match from beginning of whole word. For example, if the title is "Password for foobar.com", it can be found by searching "foo" / "com" / "pass" but not by "bar".

That is the limitation of the database search feature and to be backward compatible with older Android devices. Maybe in the future we can utilize another search engine.

## Technical FAQ
**What encryption algorithm is used?**

AndSafe uses AES in CBC mode with 256 bits key, which is generated by scrypt. AES implementation in Dart is by [Pointy Castle](https://pub.dev/packages/pointycastle). To improve performance, scrypt is using a native C implementation by [Colin Percival](https://github.com/Tarsnap/scrypt).

**Why each note is encrypted with a different key? Why not just use a single master key for all notes?**

The original AndSafe v1 (called AndroidSafe back then) had a feature to share individual encrypted note. Hence it needed to use the password to derive the encryption key for each note.
And that is why it take time to change password or importing notes, as the key needs to be generated for each note for encryption / decryption.

## Acknowledgement
- App icon: from [DelliPack](https://www.smashingmagazine.com/2008/07/55-free-high-quality-icon-sets/#dellipack), by [Wendell Fernandes](http://dellustrations.deviantart.com/)

11 changes: 11 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
10 changes: 10 additions & 0 deletions android/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.4.1)

add_library(crypto_scrypt
# as a shared library
SHARED
# source files
src/main/native/crypto_scrypt-nosse.c src/main/native/sha256.c)

target_compile_definitions (crypto_scrypt PUBLIC HAVE_CONFIG_H)

77 changes: 77 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
compileSdkVersion 30

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
applicationId "net.clarenceho.andsafe3"
minSdkVersion 19
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
externalNativeBuild {
// Encapsulates your CMake build configurations.
cmake {
// Provides a relative path to your CMake build script.
path "CMakeLists.txt"
}
}
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
7 changes: 7 additions & 0 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.clarenceho.andsafe">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
42 changes: 42 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.clarenceho.andsafe">
<application
android:label="AndSafe3"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<!-- this is causing error in older android. https://github.com/flutter/gallery/issues/383
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>-->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Binary file added android/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.clarenceho.andsafe

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}
10 changes: 10 additions & 0 deletions android/app/src/main/native/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#define HAVE_DECL_BE64ENC 0
#define HAVE_MMAP 1

#ifndef __ANDROID__
#define HAVE_POSIX_MEMALIGN 1
#endif

#ifdef __ANDROID__
#include <sys/limits.h>
#endif
Loading

0 comments on commit eaced01

Please sign in to comment.