@@ -0,0 +1,2255 @@
+/*%0A * Copyright 2014 http://Bither.net%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *    http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage net.bither.bitherj.crypto;%0A%0A%0Aimport java.util.Arrays;%0A%0Apublic class SecureCharSequence implements CharSequence %7B%0A    private char%5B%5D chars;%0A%0A    public SecureCharSequence(CharSequence charSequence) %7B%0A        this(charSequence, 0, charSequence.length());%0A    %7D%0A%0A    public SecureCharSequence(char%5B%5D chars) %7B%0A        wipe();%0A        this.chars = chars;%0A    %7D%0A%0A    private SecureCharSequence(CharSequence charSequence, int start, int end) %7B%0A        // pulled from http://stackoverflow.com/a/15844273%0A        wipe();%0A        int length = end - start;%0A        chars = new char%5Blength%5D;%0A        for (int i = start;%0A             i %3C end;%0A             i++) %7B%0A            chars%5Bi - start%5D = charSequence.charAt(i);%0A        %7D%0A    %7D%0A%0A    public void wipe() %7B%0A        if (chars != null) %7B%0A            Arrays.fill(chars, ' ');%0A        %7D%0A    %7D%0A%0A    protected void finalize() %7B%0A        wipe();%0A    %7D%0A%0A    @Override%0A    public int length() %7B%0A        if (chars != null) %7B%0A            return chars.length;%0A        %7D%0A        return 0;%0A    %7D%0A%0A    @Override%0A    public char charAt(int index) %7B%0A        if (chars != null) %7B%0A            return chars%5Bindex%5D;%0A        %7D%0A        return 0;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        return String.valueOf(this.chars);%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object o) %7B%0A        if (o instanceof SecureCharSequence) %7B%0A            return Arrays.equals(chars, ((SecureCharSequence) o).chars);%0A        %7D%0A        return false;%0A    %7D%0A%0A    @Override%0A    public CharSequence subSequence(int start, int end) %7B%0A        SecureCharSequence s = new SecureCharSequence(this, start, end);%0A        return s;%0A    %7D%0A%7D%0A

add secureCharSequence