majid2
جمعه 16 تیر 1391, 19:49 عصر
با سلام
لطفا تابع decrypt زیر را که با جاوا نوشته شده را به دلفی تبدیل کنید(باید دقیقا همین کد ها باشند)
public void decrypt(String textToDecrypt) {
, String keyString="10203040"
Cipher cipher;
try {
cipher = Cipher.getInstance("DES");
} catch (Exception ex) {
System.out.println(ex.toString());
return;
}
byte[] keyData = keyString.getBytes();
SecretKeySpec key = new SecretKeySpec(keyData, 0, keyData.length, "DES");
try {
cipher.init(Cipher.DECRYPT_MODE, key);
} catch (Exception ex) {
System.out.println("2. " + ex.toString());
return;
}
int cypheredBytes = 0;
byte[] inputBytes;
try {
inputBytes = textToDecrypt.getBytes("UTF-8");
// inputBytes = textToDecrypt.getBytes();
} catch (Exception ex) {
System.out.println("3. " + ex.toString());
return;
}
byte[] outputBytes = new byte[100];
try {
cypheredBytes = cipher.doFinal(inputBytes, 0, inputBytes.length,
outputBytes, 0);
} catch (Exception ex) {
System.out.println("4. " + ex.toString());
return;
}
String str = new String(outputBytes, 0, cypheredBytes);
System.out.println("Decrypted string = " + str);
}
}
لطفا دقیقا همین کد ها تبدیل شود چون فیلد های دارم که با جاوا Encrypt شده اند و در تیبل ذخیره شده اند حال می خواهم با دلفی این تیبل را بخوانم لطفا راهنمائی فرمائید.
لطفا تابع decrypt زیر را که با جاوا نوشته شده را به دلفی تبدیل کنید(باید دقیقا همین کد ها باشند)
public void decrypt(String textToDecrypt) {
, String keyString="10203040"
Cipher cipher;
try {
cipher = Cipher.getInstance("DES");
} catch (Exception ex) {
System.out.println(ex.toString());
return;
}
byte[] keyData = keyString.getBytes();
SecretKeySpec key = new SecretKeySpec(keyData, 0, keyData.length, "DES");
try {
cipher.init(Cipher.DECRYPT_MODE, key);
} catch (Exception ex) {
System.out.println("2. " + ex.toString());
return;
}
int cypheredBytes = 0;
byte[] inputBytes;
try {
inputBytes = textToDecrypt.getBytes("UTF-8");
// inputBytes = textToDecrypt.getBytes();
} catch (Exception ex) {
System.out.println("3. " + ex.toString());
return;
}
byte[] outputBytes = new byte[100];
try {
cypheredBytes = cipher.doFinal(inputBytes, 0, inputBytes.length,
outputBytes, 0);
} catch (Exception ex) {
System.out.println("4. " + ex.toString());
return;
}
String str = new String(outputBytes, 0, cypheredBytes);
System.out.println("Decrypted string = " + str);
}
}
لطفا دقیقا همین کد ها تبدیل شود چون فیلد های دارم که با جاوا Encrypt شده اند و در تیبل ذخیره شده اند حال می خواهم با دلفی این تیبل را بخوانم لطفا راهنمائی فرمائید.