autojs-AES加密CBC模式的IV不存在的

简介: 牙叔教程 简单易懂

牙叔教程 简单易懂


打印$crypto.encrypt

log($crypto.encrypt.toString());


function (data, key, algorithm, options) {
    return $crypto._cipher(data, Cipher.ENCRYPT_MODE, key, algorithm, options);
}


打印$crypto._cipher

log($crypto._cipher.toString());


function (data, mode, key, algorithm, options) {
    options = options || {};
    let cipher = Cipher.getInstance(algorithm);
    cipher.init(mode, key.toKeySpec(algorithm));
    let os;
    let isFile = options.output == "file" && options.dest;
    if (isFile) {
        os = new java.io.FileOutputStream(options.dest);
    } else {
        os = new ByteArrayOutputStream();
    }
    let cos = new CipherOutputStream(os, cipher);
    $crypto._input(data, options, (bytes, start, length) => {
        cos.write(bytes, start, length);
    }
    );
    cos.close();
    os.close();
    if (!isFile) {
        let result = os.toByteArray();
        return $crypto._output(result, options, "bytes");
    }
}


第4行是

cipher.init(mode, key.toKeySpec(algorithm));


有2个参数


java中是

var cipher = javax.crypto.Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key, iv);


有3个参数


第三个参数就是 IV


打印cipher.init

function init() {/*
void init(int,java.security.Key,java.security.AlgorithmParameters)
void init(int,java.security.Key,java.security.SecureRandom)
void init(int,java.security.Key,java.security.spec.AlgorithmParameterSpec)
void init(int,java.security.cert.Certificate,java.security.SecureRandom)
void init(int,java.security.Key)
void init(int,java.security.cert.Certificate)
void init(int,java.security.Key,java.security.AlgorithmParameters,java.security.SecureRandom)
void init(int,java.security.Key,java.security.spec.AlgorithmParameterSpec,java.security.SecureRandom)
*/}


init有多个重载 (Overload)方法,

autojs实现了两个参数的方法, 其他方法未实现

测试环境

手机: Mi 11 Pro
Android版本: 12
Autojs版本: 8.8.20


名人名言

思路是最重要的, 其他的百度, bing, stackoverflow, github, 安卓文档, autojs文档, 最后才是群里问问 --- 牙叔教程

声明

部分内容来自网络 本教程仅用于学习, 禁止用于其他用途

相关文章
|
安全 中间件 网络安全
中间件数据传输加密模式
中间件数据传输加密模式包括SSL/TLS用于网络通信安全,消息级加密(如AES、RSA)确保消息内容安全,端到端加密保证全程加密,数字签名验证数据完整性和真实来源,以及身份验证和授权控制访问。使用安全中间件,正确配置及管理安全设置也是关键。选择加密技术需依据应用场景、安全需求和性能考虑。
666 4
|
存储 算法 安全
Linux三种加密模式
Linux三种加密模式
390 0
|
数据安全/隐私保护
aes之ecb模式的加密解密
aes之ecb模式的加密解密
|
搜索推荐 安全 网络安全
AES 加密解密技术原理模式和实践
AES (Advanced Encryption Standard), aka Rijndael, is a symmetric encryption algorithm offering high security and speed over DES.
|
XML 数据库 数据安全/隐私保护
Android App规范处理中版本设置、发布模式、给数据集SQLite加密的讲解及使用(附源码 超详细必看)
Android App规范处理中版本设置、发布模式、给数据集SQLite加密的讲解及使用(附源码 超详细必看)
289 0
|
数据安全/隐私保护
ACK Acknowledgement 确认 AES Advanced Encryption Standard 高级加密标准 ATM Asynchronous Transfer Mode异步传输模式
ACK Acknowledgement 确认 AES Advanced Encryption Standard 高级加密标准 ATM Asynchronous Transfer Mode异步传输模式
219 0
|
存储 算法 数据库
常用对称加密算法之AES算法-CBC模式
常用对称加密算法之AES算法-CBC模式
1349 0
常用对称加密算法之AES算法-CBC模式
|
Go 数据安全/隐私保护
Go 实现 AES 加密 CBC 模式|Go主题月
密码分组链接模式 CBC (Cipher Block Chaining),这种模式是先将明文切分成若干小段,然后每一小段与初始块或者上一段的密文段进行异或运算后,再与密钥进行加密。
817 0
|
Linux 数据安全/隐私保护
CentOS 6.x 进入单用户模式加密
CentOS 6.x 进入单用户模式加密
595 0
|
安全 算法 网络协议
【网络原理】——图解HTTPS如何加密(通俗简单易懂)
HTTPS加密过程,明文,密文,密钥,对称加密,非对称加密,公钥和私钥,证书加密