📄 registration.java
字号:
if ( i == 0 ) {
firstNode = node;
currentNode = firstNode;
}
} else {
node = new Node( ( k++ ) % 10 );
if ( i == 51 ) {
node.setNext( firstNode );
}
}
if ( i != 0 ) {
currentNode.setNext( node );
currentNode = node;
}
}
Node p = firstNode;
/*
for ( int i = 0; i < 104; i++ ) {
System.out.print( p.getString() + " " );
p = p.getNext();
}
*/
String realKey = "";
realKey = getCircleKey( firstNode, pwd );
int g = 0;
p = firstNode;
if ( realKey.length() < 25 ) {
g = ( int )realKey.charAt( ( name.length() / 2 ) % realKey.length() ) % 52;
for ( int c = 0; c < g; c++ ) {
p = p.getNext();
}
int offset = 0;
int i = 0;
while ( realKey.length() < 25 ) {
offset += Integer.parseInt( ( int )realKey.charAt( i % realKey.length() ) + "" );
for ( int z = 0; z < offset; z++ ) {
p = p.getNext();
}
realKey += p.getString();
i++;
}
}
String str = "";
for ( int i = 0; i < realKey.length(); i++ ) {
char c = realKey.charAt( i );
int asci = ( int )c;
if ( i == 0 ) {
if ( asci <= 57 && asci >= 48 ) {
c = ( char )( 'A' + ( asci + Math.pow( i, 3 ) ) % 26 );
}
}
if ( str.contains( c + "" ) ) {
if ( asci <= 57 && asci >= 48 ) {
if ( asci % 2 == 0 ) {
str = str.replace( c, ( char )( 'A' + ( asci + Math.pow( asci / ( i + 1 ), 3 ) ) % 26 ) );
} else {
str = str.replace( c, ( char )( 'A' + ( asci + Math.pow( asci / ( i + 1 ), 2 ) ) % 26 ) );
}
c = ( char )( '0' + ( asci + Math.pow( i, 2 ) ) % 10 );
} else {
c = ( char )( 'A' + ( asci + Math.pow( i, 3 ) ) % 26 );
}
}
str += c;
}
realKey = str;
int h = 0;
String tmpString = "";
for ( int i = 0; i < realKey.length() && h <= 20; i++ ) {
tmpString += realKey.substring( h, h + 5 ) + "-";
h += 5;
}
realKey = tmpString.substring( 0, tmpString.length() - 1 );
return realKey;
}
private static String mixString( String name, String properties ) {
String result = "";
int minLength =
name.length() < properties.length() ? name.length() : properties.length();
for ( int i = 0; i < minLength; i++ ) {
if ( i % 2 == 0 ) {
result += properties.charAt( i );
} else {
result += name.charAt( i );
}
}
if ( name.length() < properties.length() ) {
result += properties.substring( minLength + 1, properties.length() );
} else if ( name.length() > properties.length() ) {
result += name.substring( minLength + 1, name.length() );
}
return result;
}
private static String getCircleKey( Node firstNode, String pwd ) {
int offset = 0;
String circleKey = "";
Node q = firstNode;
for ( int i = 0; i < pwd.length(); i++ ) {
offset += Integer.parseInt( ( int )pwd.charAt( i ) + "" );
for ( int t = 0; t < offset; t++ ) {
q = q.getNext();
}
circleKey += q.getString();
q = firstNode;
}
return circleKey;
}
public static RegistrationDetails getRegistrationDetails() {
ObjectInputStream ois = null;
RegistrationDetails savedRd = null;
try {
ois = new ObjectInputStream(
new BufferedInputStream(
new FileInputStream( registrationFile ) ) );
savedRd = ( RegistrationDetails )ois.readObject();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
ois.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return savedRd;
}
public static void saveRegistrationDetails( RegistrationDetails rd ) {
File parent = registrationFile.getParentFile();
try {
ObjectOutputStream oos =
new ObjectOutputStream(
new BufferedOutputStream(
new FileOutputStream( registrationFile ) ) );
oos.writeObject( rd );
oos.close();
} catch ( IOException e ) {
parent.mkdirs();
boolean fail = true;
try {
ObjectOutputStream oos =
new ObjectOutputStream(
new BufferedOutputStream(
new FileOutputStream( registrationFile ) ) );
oos.writeObject( rd );
oos.close();
fail = false;
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
if ( fail )
e.printStackTrace( System.err );
}
}
}
class Node {
private String s;
private Node next;
public Node( char c ) {
s = c + "";
}
public Node( int d ) {
s = d + "";
}
public String getString() {
return s;
}
public void setNext( Node next ) {
this.next = next;
}
public Node getNext() {
return next;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -