ios rncryptor(加密)和node.js jscryptor(解密)

vfwfrxfs  于 2021-09-23  发布在  Java
关注(0)|答案(0)|浏览(258)

我正在传递一个在ios上使用rncryptor创建的base 64字符串,但无法对其进行解密。将一些console.log添加到node.js库的解密函数时,它会在以下位置停止_hmac_是有效的比较。但是,我可以使用.net库进行解密,并且输出良好。
网间网操作系统

- (void) sendCommand: (NSString *) command {
    NSData *data = [command dataUsingEncoding:NSUTF8StringEncoding];

    NSString *key = @"1234567890123456789012";
    NSData *encryptedData = [RNEncryptor encryptData:data
                                        withSettings:kRNCryptorAES256Settings
                                            password:key
                                               error:&error];

    if (currentPeripheral != nil && currentPeripheral.state == CBPeripheralStateConnected) {
        [currentPeripheral writeValue:encryptedData forCharacteristic:currentCharacteristic type:CBCharacteristicWriteWithResponse];

    }

}

node.js

function decryptString(data) {
    const RNCryptor = require('jscryptor');
    const password = '1234567890123456789012';

    try {
        console.log(RNCryptor.Decrypt(data.toString('base64'), password).toString('ascii')); // undefined when trying to decrypt the iOS string
    }
    catch (e) {}
}

vb.net测试

Public Function DecryptString(encryptedString) As String
    Dim password = "1234567890123456789012"
    Dim decryptor As New Decryptor
    Dim decryptedData As String = decryptor.Decrypt(encryptedString, password)

    Return decryptedData
End Function

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题