开发者

.NET Equivalents to Java Crypto stuff

Could anybody tell me what the equivalent .N开发者_如何学CET classes/methods are to the following Java methods:

decryptCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
decryptCipher.init(2, getKey(0));
decryptCipher.doFinal(data);

where getKey() returns an object of type SecretKeySpec (data is dummy):

public static Key getKey(int cipher) {
    if (cipher == 0) {
      return new SecretKeySpec(new byte[] { 1, 1, 1, 1, 1, 1, 1, 1 }, "DES");
    }
    return new SecretKeySpec(new byte[] { 2, 2, 2, 2, 2, 2, 2, 2 }, "DES");
  }

Many thanks

Tony


The actual class which provides DES cryptography: http://msdn.microsoft.com/en-us/library/system.security.cryptography.descryptoserviceprovider.aspx In addition, you may want to read this up :) http://msdn.microsoft.com/en-us/library/92f9ye3s.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜