uTools-Manuals/docs/java/javax/crypto/SecretKeyFactory.html

469 lines
25 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="header">
<div class="subTitle">
javax.crypto
</div>
<h2 class="title" title="Class SecretKeyFactory">Class SecretKeyFactory</h2>
</div><div class="contentContainer">
<ul class="inheritance">
<li><a href="../../java/lang/Object.html" title="class in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>javax.crypto.SecretKeyFactory</li>
</ul> </li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr/> <br/> <pre>public class <span class="typeNameLabel">SecretKeyFactory</span>
extends <a href="../../java/lang/Object.html" title="class in java.lang">Object</a></pre>
<div class="block">
<span>这个类代表一个秘密密钥的工厂。</span>
<p> <span>主要工厂用于将<i>密钥</i> (类型为<code>Key</code>不透明加密密钥)转换为<i>密钥规范</i> (基础密钥材料的透明表示),反之亦然。</span> <span>秘密密钥工厂仅在秘密(对称)密钥上运行。</span> </p>
<p> <span>关键工厂是双向的,即它们允许从给定的密钥规范(密钥材料)构建一个不透明的密钥对象,或以适当的格式检索密钥对象的基础密钥材料。</span> </p>
<p> <span>应用程序开发人员应参考其提供商的文档,以了解<a href="../../javax/crypto/SecretKeyFactory.html#generateSecret-java.security.spec.KeySpec-"><code>generateSecret</code></a><a href="../../javax/crypto/SecretKeyFactory.html#getKeySpec-javax.crypto.SecretKey-java.lang.Class-"><code>getKeySpec</code></a>方法支持哪些关键规范。</span> <span>例如“SunJCE”提供商提供的DES秘密密钥工厂支持<code>DESKeySpec</code>作为DES密钥的透明表示该提供商的三重DES密钥密钥工厂支持<code>DESedeKeySpec</code>作为三重DES密钥的透明表示。</span> </p>
<p> <span>Java平台的每个实现都需要支持以下标准的<code>SecretKeyFactory</code>算法:</span> </p>
<ul>
<li> <span><tt>DES</tt></span> </li>
<li> <span><tt>DESede</tt></span> </li>
</ul>
<span>这些算法的描述<a href="../../../technotes/guides/security/StandardNames.html#SecretKeyFactory">SecretKeyFactory section</a> Java加密体系结构标准算法名称的文档。</span>
<span>请参阅发行说明文件以了解是否支持其他算法。</span>
</div>
<dl>
<dt>
<span class="simpleTagLabel">从以下版本开始:</span>
</dt>
<dd>
1.4
</dd>
<dt>
<span class="seeLabel">另请参见:</span>
</dt>
<dd>
<span><a href="../../javax/crypto/SecretKey.html" title="javax.crypto中的接口"><code>SecretKey</code></a> <a href="../../javax/crypto/spec/DESKeySpec.html" title="javax.crypto.spec中的类"><code>DESKeySpec</code></a> <a href="../../javax/crypto/spec/DESedeKeySpec.html" title="javax.crypto.spec中的类"><code>DESedeKeySpec</code></a> <a href="../../javax/crypto/spec/PBEKeySpec.html" title="javax.crypto.spec中的类"><code>PBEKeySpec</code></a></span>
</dd>
</dl> </li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- --> </a> <h3>构造方法摘要</h3>
<table border="0" cellpadding="3" cellspacing="0" class="memberSummary" summary="Constructor Summary table, listing constructors, and an explanation">
<caption>
<span>构造方法</span>
<span class="tabEnd"> </span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col">Modifier</th>
<th class="colLast" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected </code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#SecretKeyFactory-javax.crypto.SecretKeyFactorySpi-java.security.Provider-java.lang.String-">SecretKeyFactory</a></span>(<a href="../../javax/crypto/SecretKeyFactorySpi.html" title="class in javax.crypto">SecretKeyFactorySpi</a> keyFacSpi, <a href="../../java/security/Provider.html" title="class in java.security">Provider</a> provider, <a href="../../java/lang/String.html" title="class in java.lang">String</a> algorithm)</code>
<div class="block">
创建一个SecretKeyFactory对象。
</div> </td>
</tr>
</tbody>
</table> </li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- --> </a> <h3>方法摘要</h3>
<table border="0" cellpadding="3" cellspacing="0" class="memberSummary" summary="Method Summary table, listing methods, and an explanation">
<caption>
<span class="activeTableTab" id="t0"><span>所有方法</span><span class="tabEnd"> </span></span>
<span class="tableTab" id="t1"><span><a href="javascript:show(1);">静态方法</a></span><span class="tabEnd"> </span></span>
<span class="tableTab" id="t2"><span><a href="javascript:show(2);">接口方法</a></span><span class="tabEnd"> </span></span>
<span class="tableTab" id="t4"><span><a href="javascript:show(8);">具体的方法</a></span><span class="tabEnd"> </span></span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor" id="i0">
<td class="colFirst"><code><a href="../../javax/crypto/SecretKey.html" title="interface in javax.crypto">SecretKey</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#generateSecret-java.security.spec.KeySpec-">generateSecret</a></span>(<a href="../../java/security/spec/KeySpec.html" title="interface in java.security.spec">KeySpec</a> keySpec)</code>
<div class="block">
根据提供的密钥规范(密钥材料)生成一个
<code>SecretKey</code>对象。
</div> </td>
</tr>
<tr class="rowColor" id="i1">
<td class="colFirst"><code><a href="../../java/lang/String.html" title="class in java.lang">String</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#getAlgorithm--">getAlgorithm</a></span>()</code>
<div class="block">
返回此
<code>SecretKeyFactory</code>对象的算法名称。
</div> </td>
</tr>
<tr class="altColor" id="i2">
<td class="colFirst"><code>static <a href="../../javax/crypto/SecretKeyFactory.html" title="class in javax.crypto">SecretKeyFactory</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#getInstance-java.lang.String-">getInstance</a></span>(<a href="../../java/lang/String.html" title="class in java.lang">String</a> algorithm)</code>
<div class="block">
返回
<code>SecretKeyFactory</code>对象转换指定算法的密钥。
</div> </td>
</tr>
<tr class="rowColor" id="i3">
<td class="colFirst"><code>static <a href="../../javax/crypto/SecretKeyFactory.html" title="class in javax.crypto">SecretKeyFactory</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#getInstance-java.lang.String-java.security.Provider-">getInstance</a></span>(<a href="../../java/lang/String.html" title="class in java.lang">String</a> algorithm, <a href="../../java/security/Provider.html" title="class in java.security">Provider</a> provider)</code>
<div class="block">
返回
<code>SecretKeyFactory</code>对象转换指定算法的密钥。
</div> </td>
</tr>
<tr class="altColor" id="i4">
<td class="colFirst"><code>static <a href="../../javax/crypto/SecretKeyFactory.html" title="class in javax.crypto">SecretKeyFactory</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#getInstance-java.lang.String-java.lang.String-">getInstance</a></span>(<a href="../../java/lang/String.html" title="class in java.lang">String</a> algorithm, <a href="../../java/lang/String.html" title="class in java.lang">String</a> provider)</code>
<div class="block">
返回
<code>SecretKeyFactory</code>对象转换指定算法的密钥。
</div> </td>
</tr>
<tr class="rowColor" id="i5">
<td class="colFirst"><code><a href="../../java/security/spec/KeySpec.html" title="interface in java.security.spec">KeySpec</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#getKeySpec-javax.crypto.SecretKey-java.lang.Class-">getKeySpec</a></span>(<a href="../../javax/crypto/SecretKey.html" title="interface in javax.crypto">SecretKey</a> key, <a href="../../java/lang/Class.html" title="class in java.lang"></a>&lt;?&gt; keySpec)</code>
<div class="block">
以请求的格式返回给定键对象的规范(关键材料)。
</div> </td>
</tr>
<tr class="altColor" id="i6">
<td class="colFirst"><code><a href="../../java/security/Provider.html" title="class in java.security">Provider</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#getProvider--">getProvider</a></span>()</code>
<div class="block">
返回此
<code>SecretKeyFactory</code>对象的提供者。
</div> </td>
</tr>
<tr class="rowColor" id="i7">
<td class="colFirst"><code><a href="../../javax/crypto/SecretKey.html" title="interface in javax.crypto">SecretKey</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../javax/crypto/SecretKeyFactory.html#translateKey-javax.crypto.SecretKey-">translateKey</a></span>(<a href="../../javax/crypto/SecretKey.html" title="interface in javax.crypto">SecretKey</a> key)</code>
<div class="block">
将其提供者可能未知或可能不受信任的关键对象转换为该秘密密钥工厂的相应密钥对象。
</div> </td>
</tr>
</tbody>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- --> </a> <h3>Methods inherited from class java.lang.<a href="../../java/lang/Object.html" title="class in java.lang">Object</a></h3> <code><a href="../../java/lang/Object.html#clone--">clone</a>, <a href="../../java/lang/Object.html#equals-java.lang.Object-">equals</a>, <a href="../../java/lang/Object.html#finalize--">finalize</a>, <a href="../../java/lang/Object.html#getClass--">getClass</a>, <a href="../../java/lang/Object.html#hashCode--">hashCode</a>, <a href="../../java/lang/Object.html#notify--">notify</a>, <a href="../../java/lang/Object.html#notifyAll--">notifyAll</a>, <a href="../../java/lang/Object.html#toString--">toString</a>, <a href="../../java/lang/Object.html#wait--">wait</a>, <a href="../../java/lang/Object.html#wait-long-">wait</a>, <a href="../../java/lang/Object.html#wait-long-int-">wait</a></code></li>
</ul> </li>
</ul> </li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- --> </a> <h3>构造方法详细信息</h3> <a name="SecretKeyFactory-javax.crypto.SecretKeyFactorySpi-java.security.Provider-java.lang.String-">
<!-- --> </a>
<ul class="blockListLast">
<li class="blockList"> <h4>SecretKeyFactory</h4> <pre>protected SecretKeyFactory(<a href="../../javax/crypto/SecretKeyFactorySpi.html" title="class in javax.crypto">SecretKeyFactorySpi</a> keyFacSpi,
<a href="../../java/security/Provider.html" title="class in java.security">Provider</a> provider,
<a href="../../java/lang/String.html" title="class in java.lang">String</a> algorithm)</pre>
<div class="block">
创建一个SecretKeyFactory对象。
</div>
<dl>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<code>keyFacSpi</code> - 代表
</dd>
<dd>
<code>provider</code> - 提供商
</dd>
<dd>
<code>algorithm</code> - 秘密密钥算法
</dd>
</dl> </li>
</ul> </li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- --> </a> <h3>方法详细信息</h3> <a name="getInstance-java.lang.String-">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>getInstance</h4> <pre>public static final <a href="../../javax/crypto/SecretKeyFactory.html" title="class in javax.crypto">SecretKeyFactory</a> getInstance(<a href="../../java/lang/String.html" title="class in java.lang">String</a> algorithm)
throws <a href="../../java/security/NoSuchAlgorithmException.html" title="class in java.security">NoSuchAlgorithmException</a></pre>
<div class="block">
<span>返回<code>SecretKeyFactory</code>对象转换指定算法的密钥。</span>
<p> <span>此方法遍历已注册的安全提供程序列表,从最优选的提供程序开始。</span> <span>返回从支持指定算法的第一个Provider中封装SecretKeyFactorySpi实现的新SecretKeyFactory对象。</span> </p>
<p> <span>请注意,注册提供商的列表可以通过<a href="../../java/security/Security.html#getProviders--"><code>Security.getProviders()</code></a>方法<a href="../../java/security/Security.html#getProviders--">检索</a></span> </p>
</div>
<dl>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<span><code>algorithm</code> - 所请求密钥算法的标准名称。</span>
<span>看到的SecretKeyFactory部分<a href="../../../technotes/guides/security/StandardNames.html#SecretKeyFactory">Java Cryptography Architecture Standard Algorithm Name Documentation</a>有关标准算法名称的信息。</span>
</dd>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
新的
<code>SecretKeyFactory</code>对象。
</dd>
<dt>
<span class="throwsLabel">异常</span>
</dt>
<dd>
<code><a href="../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - 如果指定的算法为空。
</dd>
<dd>
<code><a href="../../java/security/NoSuchAlgorithmException.html" title="class in java.security">NoSuchAlgorithmException</a></code> - 如果没有提供者支持指定算法的SecretKeyFactorySpi实现。
</dd>
<dt>
<span class="seeLabel">另请参见:</span>
</dt>
<dd>
<span><a href="../../java/security/Provider.html" title="java.security中的类"><code>Provider</code></a></span>
</dd>
</dl> </li>
</ul> <a name="getInstance-java.lang.String-java.lang.String-">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>getInstance</h4> <pre>public static final <a href="../../javax/crypto/SecretKeyFactory.html" title="class in javax.crypto">SecretKeyFactory</a> getInstance(<a href="../../java/lang/String.html" title="class in java.lang">String</a> algorithm,
<a href="../../java/lang/String.html" title="class in java.lang">String</a> provider)
throws <a href="../../java/security/NoSuchAlgorithmException.html" title="class in java.security">NoSuchAlgorithmException</a>,
<a href="../../java/security/NoSuchProviderException.html" title="class in java.security">NoSuchProviderException</a></pre>
<div class="block">
<span>返回<code>SecretKeyFactory</code>对象转换指定算法的密钥。</span>
<p> <span>返回从指定提供程序封装SecretKeyFactorySpi实现的新SecretKeyFactory对象。</span> <span>指定的提供者必须在安全提供程序列表中注册。</span> </p>
<p> <span>注意,可以通过<a href="../../java/security/Security.html#getProviders--"><code>Security.getProviders()</code></a>方法检索已注册提供商的列表。</span> </p>
</div>
<dl>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<span><code>algorithm</code> - 所请求密钥算法的标准名称。</span>
<span>看到的SecretKeyFactory部分<a href="../../../technotes/guides/security/StandardNames.html#SecretKeyFactory">Java Cryptography Architecture Standard Algorithm Name Documentation</a>有关标准算法名称的信息。</span>
</dd>
<dd>
<code>provider</code> - 提供者的名称。
</dd>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
新的
<code>SecretKeyFactory</code>对象。
</dd>
<dt>
<span class="throwsLabel">异常</span>
</dt>
<dd>
<code><a href="../../java/security/NoSuchAlgorithmException.html" title="class in java.security">NoSuchAlgorithmException</a></code> - 如果指定算法的SecretKeyFactorySpi实现不能从指定的提供者获得。
</dd>
<dd>
<code><a href="../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - 如果指定的算法为空。
</dd>
<dd>
<code><a href="../../java/security/NoSuchProviderException.html" title="class in java.security">NoSuchProviderException</a></code> - 如果指定的提供程序未在安全提供程序列表中注册。
</dd>
<dd>
<code><a href="../../java/lang/IllegalArgumentException.html" title="class in java.lang">IllegalArgumentException</a></code> - 如果
<code>provider</code>为空或为空。
</dd>
<dt>
<span class="seeLabel">另请参见:</span>
</dt>
<dd>
<span><a href="../../java/security/Provider.html" title="java.security中的类"><code>Provider</code></a></span>
</dd>
</dl> </li>
</ul> <a name="getInstance-java.lang.String-java.security.Provider-">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>getInstance</h4> <pre>public static final <a href="../../javax/crypto/SecretKeyFactory.html" title="class in javax.crypto">SecretKeyFactory</a> getInstance(<a href="../../java/lang/String.html" title="class in java.lang">String</a> algorithm,
<a href="../../java/security/Provider.html" title="class in java.security">Provider</a> provider)
throws <a href="../../java/security/NoSuchAlgorithmException.html" title="class in java.security">NoSuchAlgorithmException</a></pre>
<div class="block">
<span>返回<code>SecretKeyFactory</code>对象转换指定算法的密钥。</span>
<p> <span>返回从指定的Provider对象封装SecretKeyFactorySpi实现的新SecretKeyFactory对象。</span> <span>请注意指定的Provider对象不必在提供者列表中注册。</span> </p>
</div>
<dl>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<span><code>algorithm</code> - 所请求密钥算法的标准名称。</span>
<span>看到的SecretKeyFactory部分<a href="../../../technotes/guides/security/StandardNames.html#SecretKeyFactory">Java Cryptography Architecture Standard Algorithm Name Documentation</a>有关标准算法名称的信息。</span>
</dd>
<dd>
<code>provider</code> - 提供商。
</dd>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
新的
<code>SecretKeyFactory</code>对象。
</dd>
<dt>
<span class="throwsLabel">异常</span>
</dt>
<dd>
<code><a href="../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - 如果指定的算法为空。
</dd>
<dd>
<code><a href="../../java/security/NoSuchAlgorithmException.html" title="class in java.security">NoSuchAlgorithmException</a></code> - 如果指定的算法的SecretKeyFactorySpi实现从指定的Provider对象不可用。
</dd>
<dd>
<code><a href="../../java/lang/IllegalArgumentException.html" title="class in java.lang">IllegalArgumentException</a></code> - 如果
<code>provider</code>为空。
</dd>
<dt>
<span class="seeLabel">另请参见:</span>
</dt>
<dd>
<span><a href="../../java/security/Provider.html" title="java.security中的类"><code>Provider</code></a></span>
</dd>
</dl> </li>
</ul> <a name="getProvider--">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>getProvider</h4> <pre>public final <a href="../../java/security/Provider.html" title="class in java.security">Provider</a> getProvider()</pre>
<div class="block">
返回此
<code>SecretKeyFactory</code>对象的提供者。
</div>
<dl>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
这个
<code>SecretKeyFactory</code>对象的提供者
</dd>
</dl> </li>
</ul> <a name="getAlgorithm--">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>getAlgorithm</h4> <pre>public final <a href="../../java/lang/String.html" title="class in java.lang">String</a> getAlgorithm()</pre>
<div class="block">
<span>返回此<code>SecretKeyFactory</code>对象的算法名称。</span>
<p> <span>这是在创建此<code>SecretKeyFactory</code>对象的<code>getInstance</code>调用之一中指定的<code>getInstance</code></span> </p>
</div>
<dl>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
这个
<code>SecretKeyFactory</code>对象的算法名称。
</dd>
</dl> </li>
</ul> <a name="generateSecret-java.security.spec.KeySpec-">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>generateSecret</h4> <pre>public final <a href="../../javax/crypto/SecretKey.html" title="interface in javax.crypto">SecretKey</a> generateSecret(<a href="../../java/security/spec/KeySpec.html" title="interface in java.security.spec">KeySpec</a> keySpec)
throws <a href="../../java/security/spec/InvalidKeySpecException.html" title="class in java.security.spec">InvalidKeySpecException</a></pre>
<div class="block">
从提供的密钥规范(密钥材料)生成一个
<code>SecretKey</code>对象。
</div>
<dl>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<code>keySpec</code> - 秘密密钥的规范(密钥材料)
</dd>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
密钥
</dd>
<dt>
<span class="throwsLabel">异常</span>
</dt>
<dd>
<code><a href="../../java/security/spec/InvalidKeySpecException.html" title="class in java.security.spec">InvalidKeySpecException</a></code> - 如果给定的密钥规范不适合该秘密密钥工厂生成密钥。
</dd>
</dl> </li>
</ul> <a name="getKeySpec-javax.crypto.SecretKey-java.lang.Class-">
<!-- --> </a>
<ul class="blockList">
<li class="blockList"> <h4>getKeySpec</h4> <pre>public final <a href="../../java/security/spec/KeySpec.html" title="interface in java.security.spec">KeySpec</a> getKeySpec(<a href="../../javax/crypto/SecretKey.html" title="interface in javax.crypto">SecretKey</a> key,
<a href="../../java/lang/Class.html" title="class in java.lang"></a>&lt;?&gt; keySpec)
throws <a href="../../java/security/spec/InvalidKeySpecException.html" title="class in java.security.spec">InvalidKeySpecException</a></pre>
<div class="block">
以请求的格式返回给定键对象的规范(关键材料)。
</div>
<dl>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<code>key</code> - 关键
</dd>
<dd>
<code>keySpec</code> - 要求退还关键材料的要求格式
</dd>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
请求格式的基础密钥规范(密钥材料)
</dd>
<dt>
<span class="throwsLabel">异常</span>
</dt>
<dd>
<code><a href="../../java/security/spec/InvalidKeySpecException.html" title="class in java.security.spec">InvalidKeySpecException</a></code> - 如果所请求的密钥规范对于给定的密钥是不合适的(例如,与
<code>key</code>
<code>keySpec</code>不匹配,或
<code>key</code>引用加密硬件设备上的密钥,而
<code>keySpec</code>是基于软件的密钥的规范)或者给定的密钥不能被处理(例如,给定的密钥具有该秘密密钥工厂不支持的算法或格式)。
</dd>
</dl> </li>
</ul> <a name="translateKey-javax.crypto.SecretKey-">
<!-- --> </a>
<ul class="blockListLast">
<li class="blockList"> <h4>translateKey</h4> <pre>public final <a href="../../javax/crypto/SecretKey.html" title="interface in javax.crypto">SecretKey</a> translateKey(<a href="../../javax/crypto/SecretKey.html" title="interface in javax.crypto">SecretKey</a> key)
throws <a href="../../java/security/InvalidKeyException.html" title="class in java.security">InvalidKeyException</a></pre>
<div class="block">
将其提供者可能未知或可能不受信任的关键对象转换为该秘密密钥工厂的相应密钥对象。
</div>
<dl>
<dt>
<span class="paramLabel">参数</span>
</dt>
<dd>
<code>key</code> - 提供者未知或不信任的关键
</dd>
<dt>
<span class="returnLabel">结果</span>
</dt>
<dd>
翻译密钥
</dd>
<dt>
<span class="throwsLabel">异常</span>
</dt>
<dd>
<code><a href="../../java/security/InvalidKeyException.html" title="class in java.security">InvalidKeyException</a></code> - 如果该密钥工厂无法处理给定的密钥。
</dd>
</dl> </li>
</ul> </li>
</ul> </li>
</ul>
</div>
</div>