com.sun.mail.auth.Ntlm.makeDesKey()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(13.5k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中com.sun.mail.auth.Ntlm.makeDesKey()方法的一些代码示例,展示了Ntlm.makeDesKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ntlm.makeDesKey()方法的具体详情如下:
包路径:com.sun.mail.auth.Ntlm
类名称:Ntlm
方法名:makeDesKey

Ntlm.makeDesKey介绍

[英]Convert a 7 byte array to an 8 byte array (for a des key with parity). Input starts at offset off.
[中]将7字节数组转换为8字节数组(对于具有奇偶校验的des密钥)。输入从offset off开始。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

private byte[] calcResponse(byte[] key, byte[] text)
      throws GeneralSecurityException {
  assert key.length == 21;
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
  DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  SecretKey key3 = fac.generateSecret(dks3);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key3);
  byte[] out3 = cipher.doFinal(text, 0, 8);
  byte[] result = new byte[24];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  System.arraycopy(out3, 0, result, 16, 8);
  return result;
}

代码示例来源:origin: com.sun.mail/javax.mail

private byte[] calcResponse(byte[] key, byte[] text)
      throws GeneralSecurityException {
  assert key.length == 21;
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
  DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  SecretKey key3 = fac.generateSecret(dks3);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key3);
  byte[] out3 = cipher.doFinal(text, 0, 8);
  byte[] result = new byte[24];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  System.arraycopy(out3, 0, result, 16, 8);
  return result;
}

代码示例来源:origin: com.sun.mail/javax.mail

private byte[] calcLMHash() throws GeneralSecurityException {
  byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
  byte[] pwb = null;
try {
  pwb = password.toUpperCase(Locale.ENGLISH).getBytes("iso-8859-1");
} catch (UnsupportedEncodingException ex) {
  // should never happen
  assert false;
}
  byte[] pwb1 = new byte[14];
  int len = password.length();
  if (len > 14)
    len = 14;
  System.arraycopy(pwb, 0, pwb1, 0, len); /* Zero padded */
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(pwb1, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(pwb1, 7));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(magic, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(magic, 0, 8);
  byte[] result = new byte [21];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  return result;
}

代码示例来源:origin: camunda/camunda-bpm-platform

private byte[] calcLMHash() throws GeneralSecurityException {
  byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
  byte[] pwb = null;
try {
  pwb = password.toUpperCase(Locale.ENGLISH).getBytes("iso-8859-1");
} catch (UnsupportedEncodingException ex) {
  // should never happen
  assert false;
}
  byte[] pwb1 = new byte[14];
  int len = password.length();
  if (len > 14)
    len = 14;
  System.arraycopy(pwb, 0, pwb1, 0, len); /* Zero padded */
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(pwb1, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(pwb1, 7));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(magic, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(magic, 0, 8);
  byte[] result = new byte [21];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  return result;
}

代码示例来源:origin: com.sun.mail/jakarta.mail

private byte[] calcResponse(byte[] key, byte[] text)
      throws GeneralSecurityException {
  assert key.length == 21;
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
  DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  SecretKey key3 = fac.generateSecret(dks3);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key3);
  byte[] out3 = cipher.doFinal(text, 0, 8);
  byte[] result = new byte[24];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  System.arraycopy(out3, 0, result, 16, 8);
  return result;
}

代码示例来源:origin: com.sun.mail/android-mail

private byte[] calcResponse(byte[] key, byte[] text)
      throws GeneralSecurityException {
  assert key.length == 21;
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
  DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  SecretKey key3 = fac.generateSecret(dks3);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key3);
  byte[] out3 = cipher.doFinal(text, 0, 8);
  byte[] result = new byte[24];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  System.arraycopy(out3, 0, result, 16, 8);
  return result;
}

代码示例来源:origin: com.sun.mail/mailapi

private byte[] calcResponse(byte[] key, byte[] text)
      throws GeneralSecurityException {
  assert key.length == 21;
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
  DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  SecretKey key3 = fac.generateSecret(dks3);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key3);
  byte[] out3 = cipher.doFinal(text, 0, 8);
  byte[] result = new byte[24];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  System.arraycopy(out3, 0, result, 16, 8);
  return result;
}

代码示例来源:origin: javax.mail/com.springsource.javax.mail

private byte[] calcResponse(byte[] key, byte[] text)
      throws GeneralSecurityException {
  assert key.length == 21;
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
  DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  SecretKey key3 = fac.generateSecret(dks3);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key3);
  byte[] out3 = cipher.doFinal(text, 0, 8);
  byte[] result = new byte[24];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  System.arraycopy(out3, 0, result, 16, 8);
  return result;
}

代码示例来源:origin: org.glassfish.metro/webservices-extra

private byte[] calcResponse(byte[] key, byte[] text)
      throws GeneralSecurityException {
  assert key.length == 21;
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
  DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  SecretKey key3 = fac.generateSecret(dks3);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key3);
  byte[] out3 = cipher.doFinal(text, 0, 8);
  byte[] result = new byte[24];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  System.arraycopy(out3, 0, result, 16, 8);
  return result;
}

代码示例来源:origin: jboss/jboss-javaee-specs

private byte[] calcResponse(byte[] key, byte[] text)
      throws GeneralSecurityException {
  assert key.length == 21;
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7));
  DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  SecretKey key3 = fac.generateSecret(dks3);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(text, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key3);
  byte[] out3 = cipher.doFinal(text, 0, 8);
  byte[] result = new byte[24];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  System.arraycopy(out3, 0, result, 16, 8);
  return result;
}

代码示例来源:origin: javax.mail/com.springsource.javax.mail

private byte[] calcLMHash() throws GeneralSecurityException {
  byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
  byte[] pwb = null;
try {
  pwb = password.toUpperCase(Locale.ENGLISH).getBytes("iso-8859-1");
} catch (UnsupportedEncodingException ex) {
  // should never happen
  assert false;
}
  byte[] pwb1 = new byte[14];
  int len = password.length();
  if (len > 14)
    len = 14;
  System.arraycopy(pwb, 0, pwb1, 0, len); /* Zero padded */
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(pwb1, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(pwb1, 7));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(magic, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(magic, 0, 8);
  byte[] result = new byte [21];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  return result;
}

代码示例来源:origin: com.sun.mail/mailapi

private byte[] calcLMHash() throws GeneralSecurityException {
  byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
  byte[] pwb = null;
try {
  pwb = password.toUpperCase(Locale.ENGLISH).getBytes("iso-8859-1");
} catch (UnsupportedEncodingException ex) {
  // should never happen
  assert false;
}
  byte[] pwb1 = new byte[14];
  int len = password.length();
  if (len > 14)
    len = 14;
  System.arraycopy(pwb, 0, pwb1, 0, len); /* Zero padded */
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(pwb1, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(pwb1, 7));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(magic, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(magic, 0, 8);
  byte[] result = new byte [21];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  return result;
}

代码示例来源:origin: com.sun.mail/jakarta.mail

private byte[] calcLMHash() throws GeneralSecurityException {
  byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
  byte[] pwb = null;
try {
  pwb = password.toUpperCase(Locale.ENGLISH).getBytes("iso-8859-1");
} catch (UnsupportedEncodingException ex) {
  // should never happen
  assert false;
}
  byte[] pwb1 = new byte[14];
  int len = password.length();
  if (len > 14)
    len = 14;
  System.arraycopy(pwb, 0, pwb1, 0, len); /* Zero padded */
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(pwb1, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(pwb1, 7));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(magic, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(magic, 0, 8);
  byte[] result = new byte [21];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  return result;
}

代码示例来源:origin: com.sun.mail/android-mail

private byte[] calcLMHash() throws GeneralSecurityException {
  byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
  byte[] pwb = null;
try {
  pwb = password.toUpperCase(Locale.ENGLISH).getBytes("iso-8859-1");
} catch (UnsupportedEncodingException ex) {
  // should never happen
  assert false;
}
  byte[] pwb1 = new byte[14];
  int len = password.length();
  if (len > 14)
    len = 14;
  System.arraycopy(pwb, 0, pwb1, 0, len); /* Zero padded */
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(pwb1, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(pwb1, 7));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(magic, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(magic, 0, 8);
  byte[] result = new byte [21];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  return result;
}

代码示例来源:origin: org.glassfish.metro/webservices-extra

private byte[] calcLMHash() throws GeneralSecurityException {
  byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
  byte[] pwb = null;
try {
  pwb = password.toUpperCase(Locale.ENGLISH).getBytes("iso-8859-1");
} catch (UnsupportedEncodingException ex) {
  // should never happen
  assert false;
}
  byte[] pwb1 = new byte[14];
  int len = password.length();
  if (len > 14)
    len = 14;
  System.arraycopy(pwb, 0, pwb1, 0, len); /* Zero padded */
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(pwb1, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(pwb1, 7));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(magic, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(magic, 0, 8);
  byte[] result = new byte [21];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  return result;
}

代码示例来源:origin: jboss/jboss-javaee-specs

private byte[] calcLMHash() throws GeneralSecurityException {
  byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
  byte[] pwb = null;
try {
  pwb = password.toUpperCase(Locale.ENGLISH).getBytes("iso-8859-1");
} catch (UnsupportedEncodingException ex) {
  // should never happen
  assert false;
}
  byte[] pwb1 = new byte[14];
  int len = password.length();
  if (len > 14)
    len = 14;
  System.arraycopy(pwb, 0, pwb1, 0, len); /* Zero padded */
  DESKeySpec dks1 = new DESKeySpec(makeDesKey(pwb1, 0));
  DESKeySpec dks2 = new DESKeySpec(makeDesKey(pwb1, 7));
  SecretKey key1 = fac.generateSecret(dks1);
  SecretKey key2 = fac.generateSecret(dks2);
  cipher.init(Cipher.ENCRYPT_MODE, key1);
  byte[] out1 = cipher.doFinal(magic, 0, 8);
  cipher.init(Cipher.ENCRYPT_MODE, key2);
  byte[] out2 = cipher.doFinal(magic, 0, 8);
  byte[] result = new byte [21];
  System.arraycopy(out1, 0, result, 0, 8);
  System.arraycopy(out2, 0, result, 8, 8);
  return result;
}

相关文章