0
私はVB.Netのスニペットを見つけられなかったので、私はここにJavaの断片を持っています。VB.Netに変換することが可能かどうか疑問に思っていた -この関数のJavaへのVB.Netの変換
private static byte[] SHA1(final String in)
throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(in.getBytes("iso-8859-1"), 0, in.length());
return md.digest();
}
public static String decryptSHA1(String key, final String start) {
final String delim = "a";
if (start == null)
return null;
byte[] hashedkey;
byte[] password;
int i;
try {
hashedkey = SHA1(key);
} catch (final NoSuchAlgorithmException e) {
e.printStackTrace();
return start;
} catch (final UnsupportedEncodingException e) {
e.printStackTrace();
return start;
}
final String[] temp = start.split(delim);
password = new byte[temp.length];
for (i = 0; i < hashedkey.length; i++) {
final int temp2 = Integer.parseInt(temp[i]);
if (hashedkey[i] == temp2) {
break;
} else {
password[i] = (byte) (temp2 - hashedkey[i]);
}
}
return new String(password, 0, i);
}
ありがとうございました。
VB.Netに何かを翻訳することは可能です。しかし、C#は簡単になります - それを使用できない理由は何ですか? –
C#変換で十分ですが、Javaだけで何の経験もありません。 –
ある言語から別の言語への関数(または2つ)の行単位のポートではなく...関数が何をしているのかを理解し、それを目的の言語で直接実装するのはどうですか? (使用可能な組み込み機能を持っている可能性があります) – David