gf771115的留言板

gf771115 2020-01-02 06:42:52
大家好,这里是我的留言板,如果有问题,欢迎大家留言,我会第一时间进行回复
...全文
72 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_47289497 2021-01-07
  • 打赏
  • 举报
回复
你好,我想请教一下,安卓模拟第三方支付,账户的余额叠加怎么实现的呢
  • 打赏
  • 举报
回复
你好,兄弟。可以帮我看看这个怎么转换为云函数么
public class AesEntryDetry {
// 加密秘钥 ,16个字节也就是128 bit
private static final byte[] AES_KEY = { 需要和硬件统一 };
// 加密方法
public static String encrypt(byte[] bs) throws Exception {
SecretKeySpec skeySpec = new SecretKeySpec(AES_KEY, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
if(bs.length < 16){
bs = Arrays.copyOf(bs, 16);
}
byte[] encrypted = cipher.doFinal(bs);
return BytetohexString(encrypted);
}
// 解密方法
public static String decrypt(byte[] bs)throws Exception {
SecretKeySpec skeySpec = new SecretKeySpec(AES_KEY, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] decrypted = cipher.doFinal(bs);
return BytetohexString(decrypted);
}
// 字节数组按照一定格式转换拼装成字符串
private static String BytetohexString(byte[] b) {
int len = b.length;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < len; i++) {
if (i < len - 1){
sb.append(b[i]);
sb.append(",");
}else{
sb.append(b[i]);
}
}
return sb.toString();
}

public static byte[] hex2Bytes(String src){
byte[] res = new byte[src.length()/2];
char[] chs = src.toCharArray();
int[] b = new int[2];

for(int i=0,c=0; i<chs.length; i+=2,c++){
for(int j=0; j<2; j++){
if(chs[i+j]>='0' && chs[i+j]<='9'){
b[j] = (chs[i+j]-'0');
}else if(chs[i+j]>='A' && chs[i+j]<='F'){
b[j] = (chs[i+j]-'A'+10);
}else if(chs[i+j]>='a' && chs[i+j]<='f'){
b[j] = (chs[i+j]-'a'+10);
}
}
b[0] = (b[0]&0x0f)<<4;
b[1] = (b[1]&0x0f);
res[c] = (byte) (b[0] | b[1]);
}
return res;
}
}

594

社区成员

发帖
与我相关
我的任务
社区描述
提出问题
其他 技术论坛(原bbs)
社区管理员
  • community_281
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧