diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0d71ff6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+.idea/**
+.idea/*
+.idea
+*.iml
+out/**
+out/*
+lib/**
+lib/*
+target/**
+target/*
+build.7z
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..2b2747e
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,101 @@
+
+
+ 4.0.0
+
+ ru.bvn13
+ encryptedpreferences
+ 1.0
+
+
+ EncryptedPreferences
+ EncryptedPreferences for Java
+ https://github.com/bvn13/EncryptedPreferences
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+
+ owner
+ Vyacheslav Boyko
+ mail4bvn@gmail.com
+ UTC+3
+
+
+
+
+ 1.8
+ github
+ 0.12
+
+ https://github.com/bvn13/EncryptedPreferences
+
+
+
+
+ internal.repo
+ Temporary Staging Repository
+ file://${project.build.directory}/mvn-repo
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ ${java.version}
+
+
+
+ maven-compiler-plugin
+
+
+ ${java.version}
+
+
+
+
+ maven-deploy-plugin
+ 2.8.2
+
+ internal.repo::default::file://${project.build.directory}/mvn-repo
+
+
+
+ com.github.github
+ site-maven-plugin
+ ${github.maven-plugin}
+
+ Maven artifacts for ${project.version}
+ true
+ ${project.build.directory}/mvn-repo
+ refs/heads/mvn-repo
+ **/*
+ EncryptedPreferences
+ bvn13
+
+
+
+
+ site
+
+ deploy
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/ru/bvn13/encryptedpreferences/DelegatedPreferences.java b/src/main/java/ru/bvn13/encryptedpreferences/DelegatedPreferences.java
new file mode 100644
index 0000000..88db0b4
--- /dev/null
+++ b/src/main/java/ru/bvn13/encryptedpreferences/DelegatedPreferences.java
@@ -0,0 +1,91 @@
+package ru.bvn13.encryptedpreferences;
+
+import java.util.prefs.*;
+
+/**
+ * Created by bvn13 on 22.06.2017.
+ */
+public class DelegatedPreferences extends AbstractPreferences
+{
+ private AbstractPreferences target;
+ static private final boolean verbose = false;
+
+ protected DelegatedPreferences( AbstractPreferences parent, String name,
+ AbstractPreferences target ) {
+ super( parent, name );
+ this.target = target;
+ }
+
+ protected String getSpi( String key ) {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:getSpi( "+key+" )" );
+ }
+
+ return target.get( key, null );
+ }
+
+ protected void putSpi( String key, String value ) {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:putSpi( "+key+", "+value+" )" );
+ }
+
+ target.put( key, value );
+ }
+
+ protected void removeSpi( String key ) {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:removeSpi( "+key+" )" );
+ }
+
+ target.remove( key );
+ }
+
+ protected AbstractPreferences childSpi( String name ) {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:chlidSpi( "+name+" )" );
+ }
+
+ return (AbstractPreferences)target.node( name );
+ }
+
+ protected void removeNodeSpi() throws BackingStoreException {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:removeNode()" );
+ }
+
+ target.removeNode();
+ }
+
+ protected String[] keysSpi() throws BackingStoreException {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:keysSpi()" );
+ }
+
+ return target.keys();
+ }
+
+ protected String[] childrenNamesSpi() throws BackingStoreException {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:childrenNamesSpi()" );
+ }
+
+ return target.childrenNames();
+ }
+
+ protected void syncSpi() throws BackingStoreException {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:sync()" );
+ }
+
+ target.sync();
+ }
+
+
+ protected void flushSpi() throws BackingStoreException {
+ if (verbose) {
+ System.out.println( "DP["+target+"]:flush()" );
+ }
+
+ target.flush();
+ }
+}
diff --git a/src/main/java/ru/bvn13/encryptedpreferences/EncryptedPreferences.java b/src/main/java/ru/bvn13/encryptedpreferences/EncryptedPreferences.java
new file mode 100644
index 0000000..5ac0050
--- /dev/null
+++ b/src/main/java/ru/bvn13/encryptedpreferences/EncryptedPreferences.java
@@ -0,0 +1,82 @@
+package ru.bvn13.encryptedpreferences;
+
+import java.security.*;
+import java.util.prefs.*;
+import javax.crypto.*;
+import javax.crypto.spec.*;
+
+
+/**
+ * Created by bvn13 on 22.06.2017.
+ */
+public class EncryptedPreferences extends ObfuscatedPreferences
+{
+ private EncryptionStuff stuff;
+
+ protected EncryptedPreferences( AbstractPreferences parent, String name,
+ AbstractPreferences target ) {
+ super( parent, name, target );
+ }
+
+ private void setStuff( EncryptionStuff stuff ) {
+ this.stuff = stuff;
+ }
+
+ private EncryptionStuff getStuff() {
+ return stuff;
+ }
+
+ public String obfuscateString( String string ) {
+ try {
+ return getStuff().obfuscateString( string );
+ } catch( GeneralSecurityException gse ) {
+ gse.printStackTrace();
+ }
+ return null;
+ }
+
+ public String deObfuscateString( String string ) {
+ try {
+ return getStuff().deObfuscateString( string );
+ } catch( GeneralSecurityException gse ) {
+ gse.printStackTrace();
+ }
+ return null;
+ }
+
+ public WrappedPreferences wrapChild( WrappedPreferences parent,
+ String name,
+ AbstractPreferences child ) {
+ EncryptedPreferences ep = new EncryptedPreferences( parent, name, child );
+ ep.setStuff( stuff );
+ return ep;
+ }
+
+ static public Preferences userNodeForPackage( Class clasz,
+ SecretKey secretKey ) {
+ AbstractPreferences ap =
+ (AbstractPreferences)Preferences.userNodeForPackage( clasz );
+ EncryptedPreferences ep = new EncryptedPreferences( null, "", ap );
+ try {
+ ep.setStuff( new EncryptionStuff( secretKey ) );
+ return ep;
+ } catch( GeneralSecurityException gse ) {
+ gse.printStackTrace();
+ }
+ return null;
+ }
+
+ static public Preferences systemNodeForPackage( Class clasz,
+ SecretKey secretKey ) {
+ AbstractPreferences ap =
+ (AbstractPreferences)Preferences.systemNodeForPackage( clasz );
+ EncryptedPreferences ep = new EncryptedPreferences( null, "", ap );
+ try {
+ ep.setStuff( new EncryptionStuff( secretKey ) );
+ return ep;
+ } catch( GeneralSecurityException gse ) {
+ gse.printStackTrace();
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/ru/bvn13/encryptedpreferences/EncryptionStuff.java b/src/main/java/ru/bvn13/encryptedpreferences/EncryptionStuff.java
new file mode 100644
index 0000000..a3c056f
--- /dev/null
+++ b/src/main/java/ru/bvn13/encryptedpreferences/EncryptionStuff.java
@@ -0,0 +1,72 @@
+package ru.bvn13.encryptedpreferences;
+
+import java.security.*;
+import javax.crypto.*;
+import javax.crypto.spec.*;
+
+/**
+ * Created by bvn13 on 22.06.2017.
+ */
+public class EncryptionStuff
+{
+ static private final String algorithm = "DES";
+ static private SecureRandom sr = new SecureRandom();
+ private SecretKey secretKey;
+ private Cipher cipher;
+
+ public EncryptionStuff( SecretKey secretKey ) throws GeneralSecurityException {
+ this.secretKey = secretKey;
+
+ cipher = Cipher.getInstance( algorithm );
+ }
+
+ public String arrayToString( byte raw[] ) {
+ StringBuffer sb = new StringBuffer();
+ for (int i=0; i0)
+ s += 256;
+ int hi = s>>4;
+ int lo = s&0xf;
+ sb.append( (char)('a'+hi) );
+ sb.append( (char)('a'+lo) );
+ }
+ return sb.toString();
+ }
+
+ public byte[] stringToArray( String string ) {
+ StringBuffer sb = new StringBuffer( string );
+ int len = sb.length();
+
+ if ((len&1)==1)
+ throw new RuntimeException( "String must be of even length! "+string );
+
+ byte raw[] = new byte[len/2];
+ int ii=0;
+ for (int i=0; i