⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 generatekey.java

📁 java类加密保护类
💻 JAVA
字号:
package com.tmri.sourcesafe;
// GenerateKey.java

import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;

public class GenerateKey
{
  static public void main(String args[] )
  {
      GenerateKey genKey=new GenerateKey();
      try
      {
	  genKey.test();
      }
      catch(Exception ex)
      {
	  ex.printStackTrace();
      }
  }
  public void test()  throws Exception
  {
      String algorithm = "DES";
      String keyFilename="key.data";

      // 生成密匙
      SecureRandom sr = new SecureRandom();
      KeyGenerator kg = KeyGenerator.getInstance( algorithm );
      kg.init( sr );
      SecretKey key = kg.generateKey();

      // 把密匙数据保存到文件
      Util.writeFile( keyFilename, key.getEncoded() );

  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -