本文整理汇总了Java中com.sun.spot.security.MessageDigest类的典型用法代码示例。如果您正苦于以下问题:Java MessageDigest类的具体用法?Java MessageDigest怎么用?Java MessageDigest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageDigest类属于com.sun.spot.security包,在下文中一共展示了MessageDigest类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Handshake
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/**
* Creates an Handshake object that is used to negotiate a
* version 3 handshake with an SSL peer.
*
* @param host hostname of the peer
* @param port port number of the peer
* @param r Record instance through which handshake
* will occur
* @param tcs trusted certificate store containing certificates
*
* @exception RuntimeException if SHA-1 or MD5 is not available
*/
Handshake(String host, int port, Record r, CertStore tcs) {
trustManager = TrustManager.getTrustManager(); // SPOT specific
peerHost = new String(host);
peerPort = port;
rec = r;
certStore = tcs;
sPrivKey = null;
gotCertReq = 0;
start = 0;
cnt = 0;
try {
ourMD5 = MessageDigest.getInstance("MD5");
ourSHA = MessageDigest.getInstance("SHA-1");
rnd = SecureRandom.getInstance(SecureRandom.ALG_SECURE_RANDOM);
} catch (NoSuchAlgorithmException e) {
// should only happen, if digests are not included in the build
throw new RuntimeException(e.getMessage());
}
}
示例2: RsaMd5Sig
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/**
* Constructs an RSA signature object that uses MD5 as
* message digest algorithm.
*
* @exception RuntimeException if MD5 is not available
*/
public RsaMd5Sig() {
try {
rsaSig = new RSASig(PREFIX_MD5, MessageDigest.getInstance("MD5"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Needed algorithm not available");
}
}
示例3: RsaShaSig
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/**
* Constructs an RSA signature object that uses SHA1 as
* message digest algorithm.
*
* @exception RuntimeException if SHA-1 is not available
*/
public RsaShaSig() {
try {
rsaSig =
new RSASig(PREFIX_SHA1, MessageDigest.getInstance("SHA-1"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Needed algorithm not available");
}
}
示例4: RSASig
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/**
* Constructs an RSA signature object that uses the specified
* signature algorithm.
*
* @param sigPrefix Prefix for the signature
* @param messageDigest Message digest for the signature
*
* @exception NoSuchAlgorithmException if RSA is
* not available in the caller's environment.
*/
RSASig(byte[] sigPrefix, MessageDigest messageDigest)
throws NoSuchAlgorithmException {
prefix = sigPrefix;
md = messageDigest;
try {
c = Cipher.getInstance("RSA");
} catch (NoSuchPaddingException e) {
// we used the default mode and padding this should not happen
throw new NoSuchAlgorithmException();
}
}
示例5: PseudoRand
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/** Constructor for random data. */
public PseudoRand() throws NoSuchAlgorithmException {
if (md != null)
return;
try {
md = MessageDigest.getInstance("MD5");
} catch (Exception e) {
throw new NoSuchAlgorithmException("Algorithm MD5 not available");
}
randomBytes = new byte[seed.length];
timeTmp = new byte[8];
updateSeed();
}
示例6: create
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
private void create(String algorithm, String hashAlg) throws NoSuchAlgorithmException {
this.algorithm = algorithm;
digest = MessageDigest.getInstance(hashAlg);
digestBuf = new byte[digest.getDigestLength()];
}
示例7: RecordEncoder
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/**
* Constructs RecordEncoder object
*
* @param dgst digest for MAC computation
* @param secret MAC secret
* @param padLen padding length
* @param cphr cipher used for encoding
* @param ver version of SSL/TLS
*/
RecordEncoder(MessageDigest dgst, byte[] secret, int padLen, Cipher cphr, byte ver) {
macSecret = secret;
digest = dgst;
digestLength = digest.getDigestLength();
padLength = padLen;
cipher = cphr;
version = ver;
}
示例8: RecordDecoder
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/**
* Constructs RecordDecoder object
*
* @param dgst digest for MAC computation
* @param secret MAC secret
* @param padLen padding length
* @param cphr cipher used for decoding
* @param ver version of SSL/TLS
*/
RecordDecoder(MessageDigest dgst, byte[] secret, int padLen, Cipher cphr, byte ver) {
macSecret = secret;
digest = dgst;
digestLength = digest.getDigestLength();
padLength = padLen;
cipher = cphr;
version = ver;
}
示例9: getEncodeDigest
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/**
* Get digest used for encoding
* @return encode digest
*/
MessageDigest getEncodeDigest() {
return encodeDigest;
}
示例10: getDecodeDigest
import com.sun.spot.security.MessageDigest; //导入依赖的package包/类
/**
* Get digest used for decoding
* @return decode digest
*/
MessageDigest getDecodeDigest() {
return decodeDigest;
}