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


Java NoSuchAlgorithmException.toString方法代碼示例

本文整理匯總了Java中java.security.NoSuchAlgorithmException.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java NoSuchAlgorithmException.toString方法的具體用法?Java NoSuchAlgorithmException.toString怎麽用?Java NoSuchAlgorithmException.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.NoSuchAlgorithmException的用法示例。


在下文中一共展示了NoSuchAlgorithmException.toString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: digestBytes

import java.security.NoSuchAlgorithmException; //導入方法依賴的package包/類
/**
 * Retrieves a byte sequence representing the MD5 digest of the
 * specified byte sequence.
 *
 * @param data the data to digest.
 * @return the MD5 digest as an array of 16 bytes.
 * @throws HsqlUnsupportedOperationException if an MD5 digest
 *       algorithm is not available through the
 *       java.security.MessageDigest spi
 */
public static final byte[] digestBytes(byte[] data)
throws RuntimeException {

    synchronized (MD5.class) {
        if (md5 == null) {
            try {
                md5 = MessageDigest.getInstance("MD5");
            } catch (NoSuchAlgorithmException e) {
                throw new RuntimeException(e.toString());
            }
        }

        return md5.digest(data);
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:MD5.java

示例2: digest

import java.security.NoSuchAlgorithmException; //導入方法依賴的package包/類
/**
 * Generate a base-64 encoded digest of the idPasswordPair pair
 * @param idPasswordPair id:password
 * @return a string that can be used for authentication
 */
public String digest(String idPasswordPair) throws IOException {
  if (StringUtils.isEmpty(idPasswordPair) || !isValid(idPasswordPair)) {
    throw new IOException("Invalid id:password: " + idPasswordPair);
  }
  try {
    return DigestAuthenticationProvider.generateDigest(idPasswordPair);
  } catch (NoSuchAlgorithmException e) {
    // unlikely since it is standard to the JVM, but maybe JCE restrictions
    // could trigger it
    throw new IOException(e.toString(), e);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:RegistrySecurity.java

示例3: getRawKey

import java.security.NoSuchAlgorithmException; //導入方法依賴的package包/類
private static byte[] getRawKey(String seedString) {
try {
	byte[] seed = ("fe-"+seedString+"-ri").getBytes(StandardCharsets.UTF_8);
      	// Create MD5 Hash
          MessageDigest digest;
	digest = java.security.MessageDigest.getInstance("MD5");
          digest.update(seed);
          byte messageDigest[] = digest.digest();
          byte[] result = new byte[16];
          System.arraycopy(messageDigest, 0, result, 0, 16);
          return result;
} catch (NoSuchAlgorithmException e) {
	throw new RuntimeException(e.toString(), e);
}
     }
 
開發者ID:ferenc-hechler,項目名稱:RollenspielAlexaSkill,代碼行數:16,代碼來源:SimpleCrypto.java

示例4: decryptChiData

import java.security.NoSuchAlgorithmException; //導入方法依賴的package包/類
static byte[] decryptChiData(byte[] data, byte[] passDigest) throws MyUtilException
{

	int length = data.length;

	int size = getChiSize(data);
	if(size < 0)
		throw new MyUtilException(R.string.error_invalid_chi, "not a valid chi file");

	if(passDigest == null)
		throw new MyUtilException(R.string.error_null_passdigest, "password input error");

	int ret = bfdecrypt(data, 8, length - 8, passDigest);
	if(ret < 0)
		throw new MyUtilException(R.string.error_blowfish, "error decrypting/encrypting");

	byte[] includedMD5 = new byte[16];
	System.arraycopy(data, 16, includedMD5, 0, 16);

	byte[] computedMD5;
	try
	{
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		md5.update(data, 32, size);
		computedMD5 = md5.digest();
	}
	catch(NoSuchAlgorithmException e)
	{
		throw new MyUtilException(R.string.error_unsupported, e.toString());
	}

	if(!MessageDigest.isEqual(includedMD5, computedMD5))
	{
		throw new MyUtilException(R.string.error_password, "Password is not correct.");
	}

	byte[] dec_data = new byte[size];
	System.arraycopy(data, 32, dec_data, 0, size);

	return dec_data;
}
 
開發者ID:monolifed,項目名稱:mininoteview,代碼行數:42,代碼來源:MyUtil.java

示例5: decryptChsData

import java.security.NoSuchAlgorithmException; //導入方法依賴的package包/類
static byte[] decryptChsData(byte[] data, byte[] passDigest) throws MyUtilException
{

	int length = data.length;

	int size = getChiSize(data);
	if(size < 0)
		throw new MyUtilException(R.string.error_invalid_chi, "not a valid chi file");

	if(passDigest == null)
		throw new MyUtilException(R.string.error_null_passdigest, "password input error");


	int ret = bfdecrypt(data, 8, 8, passDigest);
	if(ret < 0)
		throw new MyUtilException(R.string.error_blowfish, "error decrypting/encrypting");

	byte[] iv = new byte[8];
	System.arraycopy(data, 8, iv, 0, 8);
	ret = bfdecrypt(data, 16, length - 16, passDigest, iv);
	if(ret < 0)
		throw new MyUtilException(R.string.error_blowfish, "error decrypting/encrypting");

	byte[] includedMD5 = new byte[16];
	System.arraycopy(data, 16, includedMD5, 0, 16);

	byte[] computedMD5;
	try
	{
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		md5.update(data, 32, size);
		computedMD5 = md5.digest();
	}
	catch(NoSuchAlgorithmException e)
	{
		throw new MyUtilException(R.string.error_unsupported, e.toString());
	}

	if(!MessageDigest.isEqual(includedMD5, computedMD5))
	{
		throw new MyUtilException(R.string.error_password, "Password is not correct.");
	}

	byte[] dec_data = new byte[size];
	System.arraycopy(data, 32, dec_data, 0, size);

	return dec_data;
}
 
開發者ID:monolifed,項目名稱:mininoteview,代碼行數:49,代碼來源:MyUtil.java


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