java吧 关注:1,292,632贴子:12,823,335
  • 3回复贴,共1

哪位朋友能帮我把java代码转成php代码

只看楼主收藏回复

谢谢


IP属地:江西1楼2019-06-18 12:31回复
    代码如下
    AES-128 数据加密的JAVA 实现:
    public static byte[] Encrypt(byte[] sSrc, byte[] sKey){
    try{
    SecretKeySpec skeySpec = new SecretKeySpec(sKey, "AES");
    Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
    cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
    byte[] encrypted = cipher.doFinal(sSrc);
    return encrypted;
    }catch(Exception ex){
    return null;
    }
    }
    AES-128 数据解密的JAVA 实现:
    public static byte[] Decrypt(byte[] sSrc, byte[] sKey){
    try{
    SecretKeySpec skeySpec = new SecretKeySpec(sKey, "AES");
    Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
    cipher.init(Cipher.DECRYPT_MODE, skeySpec);
    byte[] dncrypted = cipher.doFinal(sSrc);
    return dncrypted;
    }catch(Exception ex){
    return null;
    }
    }


    IP属地:江西2楼2019-06-18 12:32
    收起回复
      2025-12-26 19:23:22
      广告
      不感兴趣
      开通SVIP免广告
      求帮助


      IP属地:江西3楼2019-06-18 17:33
      回复