本文整理匯總了Java中java.security.spec.EncodedKeySpec.getEncoded方法的典型用法代碼示例。如果您正苦於以下問題:Java EncodedKeySpec.getEncoded方法的具體用法?Java EncodedKeySpec.getEncoded怎麽用?Java EncodedKeySpec.getEncoded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.spec.EncodedKeySpec
的用法示例。
在下文中一共展示了EncodedKeySpec.getEncoded方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetEncoded
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that <code>getEncoded()</code> method returns valid byte array
*/
public final void testGetEncoded() {
byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Check returned array */
boolean result = true;
for (int i = 0; i < encodedKey.length; i++) {
if (encodedKey[i] != ek[i]) {
/* indicate failure */
result = false;
}
}
/* passed */
assertTrue(result);
}
示例2: testIsStatePreserved1
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that internal state of the object can not be modified by modifying
* initial array value
*/
public final void testIsStatePreserved1() {
/* Create initial byte array */
byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Modify initial array's value */
encodedKey[3] = (byte) 5;
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Check that byte value has not been changed */
assertTrue(ek[3] == (byte) 4);
}
示例3: testIsStatePreserved2
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that internal state of the object can not be modified using
* returned value of <code>getEncoded()</code> method
*/
public final void testIsStatePreserved2() {
byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Modify returned value */
ek[3] = (byte) 5;
/* Get encoded key again */
byte[] ek1 = meks.getEncoded();
/* Check that byte value has not been changed */
assertTrue(ek1[3] == (byte) 4);
}
示例4: testGetEncoded
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that <code>getEncoded()</code> method returns valid byte array
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getEncoded",
args = {}
)
public final void testGetEncoded() {
byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Check returned array */
boolean result = true;
for (int i = 0; i < encodedKey.length; i++) {
if (encodedKey[i] != ek[i]) {
/* indicate failure */
result = false;
}
}
/* passed */
assertTrue(result);
}
示例5: testIsStatePreserved1
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that internal state of the object can not be modified by modifying
* initial array value
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "getEncoded",
args = {}
)
public final void testIsStatePreserved1() {
/* Create initial byte array */
byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Modify initial array's value */
encodedKey[3] = (byte) 5;
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Check that byte value has not been changed */
assertTrue(ek[3] == (byte) 4);
}
示例6: testIsStatePreserved2
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that internal state of the object can not be modified using
* returned value of <code>getEncoded()</code> method
*/
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "getEncoded",
args = {}
)
public final void testIsStatePreserved2() {
byte[] encodedKey = new byte[] { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Modify returned value */
ek[3] = (byte) 5;
/* Get encoded key again */
byte[] ek1 = meks.getEncoded();
/* Check that byte value has not been changed */
assertTrue(ek1[3] == (byte) 4);
}
示例7: testGetEncoded
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that <code>getEncoded()</code> method
* returns valid byte array
*/
public final void testGetEncoded() {
byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Check returned array */
boolean result = true;
for (int i=0; i<encodedKey.length; i++) {
if (encodedKey[i] != ek[i]) {
/* indicate failure */
result = false;
}
}
/* passed */
assertTrue(result);
}
示例8: testIsStatePreserved1
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that internal state of the object
* can not be modified by modifying initial array value
*/
public final void testIsStatePreserved1() {
/* Create initial byte array */
byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Modify initial array's value */
encodedKey[3] = (byte)5;
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Check that byte value has not been changed */
assertTrue(ek[3] == (byte)4);
}
示例9: testIsStatePreserved2
import java.security.spec.EncodedKeySpec; //導入方法依賴的package包/類
/**
* Tests that internal state of the object
* can not be modified using returned value
* of <code>getEncoded()</code> method
*/
public final void testIsStatePreserved2() {
byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
/* Get encoded key */
byte[] ek = meks.getEncoded();
/* Modify returned value */
ek[3] = (byte)5;
/* Get encoded key again */
byte[] ek1 = meks.getEncoded();
/* Check that byte value has not been changed */
assertTrue(ek1[3] == (byte)4);
}