GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update samples to version 2.0.0 · simbiose/Encryption@476ea17

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Encryption/gradle/wrapper
    • gradle-wrapper.properties
  • Examples
    • Android
      • app
        • build.gradle
        • src/main
          • java/se/simbio/encryption
            • MainActivity.java
          • res/layout
            • activity_main.xml
      • build.gradle
      • gradle/wrapper
        • gradle-wrapper.properties
    • Java
      • build.gradle
      • gradle/wrapper
        • gradle-wrapper.properties
      • src/se/simbio/encryption
        • Examples.java
        • Main.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Encryption/gradle/wrapper/gradle-wrapper.properties‎

Copy file name to clipboardExpand all lines: Encryption/gradle/wrapper/gradle-wrapper.properties
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Collapse file

‎Examples/Android/app/build.gradle‎

Copy file name to clipboardExpand all lines: Examples/Android/app/build.gradle
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ apply plugin: 'com.android.application'
22

33
android {
44

5-
compileSdkVersion 23
6-
buildToolsVersion '23.0.3'
5+
compileSdkVersion 24
6+
buildToolsVersion '24.0.3'
77

88
defaultConfig {
99
minSdkVersion 9
10-
targetSdkVersion 23
10+
targetSdkVersion 24
1111
}
1212

1313
}
1414

1515
dependencies {
16-
compile 'com.android.support:appcompat-v7:23.3.0'
17-
compile 'com.github.simbiose:Encryption:1.4.0'
16+
compile 'com.android.support:appcompat-v7:24.2.1'
17+
compile 'com.github.simbiose:Encryption:2.0.0'
1818
}
Collapse file

‎Examples/Android/app/src/main/java/se/simbio/encryption/MainActivity.java‎

Copy file name to clipboardExpand all lines: Examples/Android/app/src/main/java/se/simbio/encryption/MainActivity.java
+3-63Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ protected void onCreate(Bundle savedInstanceState) {
2727

2828
mTextView = (TextView) findViewById(R.id.log_textView);
2929
mTextView.setMovementMethod(new ScrollingMovementMethod());
30-
interceptLog();
3130

3231
// the Normal Usage
33-
View view = findViewById(R.id.usage_normal);
34-
assert view != null;
35-
view.setOnClickListener(new View.OnClickListener() {
32+
findViewById(R.id.usage_normal).setOnClickListener(new View.OnClickListener() {
3633
@Override
3734
public void onClick(View v) {
3835
log("---- Normal Usage ---------------------------------------------------");
@@ -58,39 +55,8 @@ public void onClick(View v) {
5855
}
5956
});
6057

61-
// the Normal Usage
62-
view = findViewById(R.id.usage_low_iteration);
63-
assert view != null;
64-
view.setOnClickListener(new View.OnClickListener() {
65-
@Override
66-
public void onClick(View v) {
67-
log("---- Low Iteration Usage --------------------------------------------");
68-
// Low iteration is equals the default but faster once it uses only 1 iteration instead of 65536
69-
Encryption encryption = Encryption.getLowIteration("SomeKey", "SomeSalt", new byte[16]);
70-
71-
String secretText = "Low iteration is faster but may you will prefer an async approach with a big iteration count";
72-
73-
// the method encryptOrNull will encrypt your text and if some error occurs will return null
74-
// if you want handle the errors you can call the encrypt method directly
75-
String encrypted = encryption.encryptOrNull(secretText);
76-
77-
// just printing to see the text and the encrypted string
78-
log("This is our secret text: " + secretText);
79-
log("And this is our encrypted text: " + encrypted);
80-
81-
// now you can send the encrypted text by network or save in disk securely or do wherever
82-
// that you want, but remember encrypt is not all, we need decrypt too, so lets go do it
83-
String decrypted = encryption.decryptOrNull(encrypted);
84-
85-
// the decrypted text should be equals the encrypted
86-
log("And finally this is our decrypted text: " + decrypted);
87-
}
88-
});
89-
9058
// a Customized Usage
91-
view = findViewById(R.id.usage_customized);
92-
assert view != null;
93-
view.setOnClickListener(new View.OnClickListener() {
59+
findViewById(R.id.usage_customized).setOnClickListener(new View.OnClickListener() {
9460
@Override
9561
public void onClick(View v) {
9662
log("---- Customized Usage -----------------------------------------------");
@@ -132,9 +98,7 @@ public void onClick(View v) {
13298
});
13399

134100
// an Async Usage
135-
view = findViewById(R.id.usage_async);
136-
assert view != null;
137-
view.setOnClickListener(new View.OnClickListener() {
101+
findViewById(R.id.usage_async).setOnClickListener(new View.OnClickListener() {
138102
@Override
139103
public void onClick(View v) {
140104
log("---- Async Usage ----------------------------------------------------");
@@ -165,30 +129,6 @@ public void onError(Exception e) {
165129
});
166130
}
167131

168-
/**
169-
* By default Encryption do not log, but you can intercept logs
170-
*/
171-
private void interceptLog() {
172-
// you can intercept logs and sed direct to System.out with:
173-
Logger.enableDefaultLog();
174-
175-
// you can turn off the log too, by default the log is off
176-
Logger.disableLog();
177-
178-
// you can also intercept the log and do wherever you want
179-
Logger.setLogDelegate(new Logger.EncryptionLogDelegate() {
180-
@Override
181-
public void log(String message, Exception e) {
182-
MainActivity.this.log("this is an exception log: " + message + ", " + e);
183-
}
184-
185-
@Override
186-
public void log(String message) {
187-
MainActivity.this.log("this is a normal log: " + message);
188-
}
189-
});
190-
}
191-
192132
private void log(final String message) {
193133
Log.d(TAG, message);
194134

Collapse file

‎Examples/Android/app/src/main/res/layout/activity_main.xml‎

Copy file name to clipboard
+4-31Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,35 @@
1-
<RelativeLayout
1+
<LinearLayout
22
xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
55
android:orientation="vertical"
6-
android:paddingBottom="16dp"
7-
android:paddingLeft="16dp"
8-
android:paddingRight="16dp"
9-
android:paddingTop="16dp">
10-
11-
<View
12-
android:id="@+id/anchor"
13-
android:layout_width="0dp"
14-
android:layout_height="0dp"
15-
android:layout_centerHorizontal="true"/>
6+
android:padding="16dp">
167

178
<Button
189
android:id="@+id/usage_normal"
19-
android:layout_width="wrap_content"
20-
android:layout_height="wrap_content"
21-
android:layout_alignParentLeft="true"
22-
android:layout_marginBottom="16dp"
23-
android:layout_toLeftOf="@+id/anchor"
24-
android:text="@string/usage_normal"/>
25-
26-
<Button
27-
android:id="@+id/usage_low_iteration"
2810
android:layout_width="match_parent"
2911
android:layout_height="wrap_content"
30-
android:layout_alignParentRight="true"
3112
android:layout_marginBottom="16dp"
32-
android:layout_toRightOf="@+id/anchor"
33-
android:text="@string/usage_low_iteration"/>
13+
android:text="@string/usage_normal"/>
3414

3515
<Button
3616
android:id="@+id/usage_customized"
3717
android:layout_width="match_parent"
3818
android:layout_height="wrap_content"
39-
android:layout_alignParentLeft="true"
40-
android:layout_below="@+id/usage_normal"
4119
android:layout_marginBottom="16dp"
42-
android:layout_toLeftOf="@+id/anchor"
4320
android:text="@string/usage_customized"/>
4421

4522
<Button
4623
android:id="@+id/usage_async"
4724
android:layout_width="match_parent"
4825
android:layout_height="wrap_content"
49-
android:layout_alignParentRight="true"
50-
android:layout_below="@+id/usage_low_iteration"
5126
android:layout_marginBottom="16dp"
52-
android:layout_toRightOf="@+id/anchor"
5327
android:text="@string/usage_async"/>
5428

5529
<TextView
5630
android:id="@+id/log_textView"
5731
android:layout_width="match_parent"
5832
android:layout_height="match_parent"
59-
android:layout_below="@id/usage_customized"
6033
android:scrollbars="vertical"/>
6134

62-
</RelativeLayout>
35+
</LinearLayout>
Collapse file

‎Examples/Android/build.gradle‎

Copy file name to clipboardExpand all lines: Examples/Android/build.gradle
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
jcenter()
44
}
55
dependencies {
6-
classpath 'com.android.tools.build:gradle:2.1.0'
6+
classpath 'com.android.tools.build:gradle:2.2.2'
77
}
88
}
99

Collapse file

‎Examples/Android/gradle/wrapper/gradle-wrapper.properties‎

Copy file name to clipboardExpand all lines: Examples/Android/gradle/wrapper/gradle-wrapper.properties
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Collapse file

‎Examples/Java/build.gradle‎

Copy file name to clipboardExpand all lines: Examples/Java/build.gradle
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apply plugin: 'java'
22

33
group 'se.simbio.encryption.java.example'
4-
version '1.0'
4+
version '2.0.0'
55

66
repositories {
77
mavenCentral()
@@ -19,5 +19,5 @@ sourceSets {
1919
}
2020

2121
dependencies {
22-
compile 'com.github.simbiose:Encryption:1.4.0'
22+
compile 'com.github.simbiose:Encryption:2.0.0'
2323
}
Collapse file

‎Examples/Java/gradle/wrapper/gradle-wrapper.properties‎

Copy file name to clipboardExpand all lines: Examples/Java/gradle/wrapper/gradle-wrapper.properties
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Collapse file

‎Examples/Java/src/se/simbio/encryption/Examples.java‎

Copy file name to clipboardExpand all lines: Examples/Java/src/se/simbio/encryption/Examples.java
+1-51Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
*/
1010
final class Examples {
1111

12-
/**
13-
* The Encryption library is easy to use
14-
*/
15-
void normalUsage() {
12+
void commonUsage() {
1613
System.out.println("---- Normal Usage ---------------------------------------------------");
1714
// it is how to get the Encryption instance. You should use your own key your own salt and your own byte array
1815
Encryption encryption = Encryption.getDefault("SomeKey", "SomeSalt", new byte[16]);
@@ -35,29 +32,6 @@ void normalUsage() {
3532
System.out.println("And finally this is our decrypted text: " + decrypted);
3633
}
3734

38-
void lowIteration() {
39-
System.out.println("---- Low Iteration Usage --------------------------------------------");
40-
// Low iteration is equals the default but faster once it uses only 1 iteration instead of 65536
41-
Encryption encryption = Encryption.getLowIteration("SomeKey", "SomeSalt", new byte[16]);
42-
43-
String secretText = "Low iteration is faster but may you will prefer an async approach with a big iteration count";
44-
45-
// the method encryptOrNull will encrypt your text and if some error occurs will return null
46-
// if you want handle the errors you can call the encrypt method directly
47-
String encrypted = encryption.encryptOrNull(secretText);
48-
49-
// just printing to see the text and the encrypted string
50-
System.out.println("This is our secret text: " + secretText);
51-
System.out.println("And this is our encrypted text: " + encrypted);
52-
53-
// now you can send the encrypted text by network or save in disk securely or do wherever
54-
// that you want, but remember encrypt is not all, we need decrypt too, so lets go do it
55-
String decrypted = encryption.decryptOrNull(encrypted);
56-
57-
// the decrypted text should be equals the encrypted
58-
System.out.println("And finally this is our decrypted text: " + decrypted);
59-
}
60-
6135
void customizedUsage() {
6236
System.out.println("---- Customized Usage -----------------------------------------------");
6337
// if you want to change Encryption behavior, maybe to reduce the Iteration Count to get a
@@ -123,28 +97,4 @@ public void onError(Exception e) {
12397
// you can do the same thing to decrypt with decryptAsync
12498
}
12599

126-
/**
127-
* By default Encryption do not log, but you can intercept logs
128-
*/
129-
void interceptLog() {
130-
// you can intercept logs and sed direct to System.out with:
131-
Logger.enableDefaultLog();
132-
133-
// you can turn off the log too, by default the log is off
134-
Logger.disableLog();
135-
136-
// you can also intercept the log and do wherever you want
137-
Logger.setLogDelegate(new Logger.EncryptionLogDelegate() {
138-
@Override
139-
public void log(String message, Exception e) {
140-
System.out.println("this is an exception log: " + message + ", " + e.toString());
141-
}
142-
143-
@Override
144-
public void log(String message) {
145-
System.out.println("this is a normal log: " + message);
146-
}
147-
});
148-
}
149-
150100
}
Collapse file

‎Examples/Java/src/se/simbio/encryption/Main.java‎

Copy file name to clipboardExpand all lines: Examples/Java/src/se/simbio/encryption/Main.java
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ final class Main {
44

55
public static void main(String[] args) {
66
Examples examples = new Examples();
7-
examples.interceptLog();
8-
examples.normalUsage();
9-
examples.lowIteration();
7+
examples.commonUsage();
108
examples.customizedUsage();
119
examples.asyncUsage();
1210
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.