當前位置: 首頁>>代碼示例>>Java>>正文


Java EncodedKeySpec.getEncoded方法代碼示例

本文整理匯總了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);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:23,代碼來源:EncodedKeySpecTest.java

示例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);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:20,代碼來源:EncodedKeySpecTest.java

示例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);
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:20,代碼來源:EncodedKeySpecTest.java

示例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);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:29,代碼來源:EncodedKeySpecTest.java

示例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);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:26,代碼來源:EncodedKeySpecTest.java

示例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);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:26,代碼來源:EncodedKeySpecTest.java

示例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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:24,代碼來源:EncodedKeySpecTest.java

示例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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:20,代碼來源:EncodedKeySpecTest.java

示例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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:21,代碼來源:EncodedKeySpecTest.java


注:本文中的java.security.spec.EncodedKeySpec.getEncoded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。