Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大佬你好,目前支持des-ecb中的pkcs7吗? #15

Open
qllqll opened this issue Feb 9, 2022 · 18 comments
Open

大佬你好,目前支持des-ecb中的pkcs7吗? #15

qllqll opened this issue Feb 9, 2022 · 18 comments

Comments

@qllqll
Copy link

qllqll commented Feb 9, 2022

No description provided.

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

并且运行之后还报了一个错误
flutter: type 'Future<Uint8List?>' is not a subtype of type 'FutureOr<List>' in type cast

@OctMon
Copy link
Owner

OctMon commented Feb 9, 2022

flutter doctor -v
看一下flutter版本

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

Flutter (Channel master, 2.10.0-1.0.pre.281, on macOS 11.3.1 20E241 darwin-x64,
locale zh-Hans-CN)
• Flutter version 2.10.0-1.0.pre.281 at /Users/wwp/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7ec334827a (2 周前), 2022-01-24 19:50:10 -0800
• Engine revision 83cfdcc8f1
• Dart version 2.17.0 (build 2.17.0-51.0.dev)
• DevTools version 2.9.2

@OctMon
Copy link
Owner

OctMon commented Feb 9, 2022

目前 stable 是没有问题的,建议使用稳定版
[✓] Flutter (Channel stable, 2.10.0, on macOS 12.2 21D49 darwin-x64, locale
zh-Hans-CN)
• Flutter version 2.10.0
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5f105a6ca7 (7 days ago), 2022-02-01 14:15:42 -0800
• Engine revision 776efd2034
• Dart version 2.16.0
• DevTools version 2.9.2

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

大佬,还是一样的,是我打开的方式不对么
flutter: type 'Future<Uint8List?>' is not a subtype of type 'FutureOr<List>' in type cast

我已经换了成
Flutter is already up to date on channel stable
Flutter 2.10.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5f105a6ca7 (7 天前) • 2022-02-01 14:15:42 -0800
Engine • revision 776efd2034
Tools • Dart 2.16.0 • DevTools 2.9.2

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

我是用encryptToBase64 这个方法会这个报错

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

List.from()用这个转就不会报错了

@OctMon
Copy link
Owner

OctMon commented Feb 9, 2022

final_key = "u1BvOHzUOcklgNpn1MaWvdn9DT4LyzSX";
final _iv = "12345678";
final _text =
"Java, android, ios, get the same result by DES encryption and decryption.";
await FlutterDes.encryptToBase64(_text, _key, iv: _iv);
我这里是正常的,方便看下你的代码不?

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

const string = "123456";
const key = "1644288237811";
const iv = "12345678";

try {
  var encryptBase64 =  await FlutterDes.encryptToBase64(string, key,iv: iv);
}catch(e){
  print(e);
}

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

就这样的 和你的没啥区别

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

还有个问题 为啥你这加密出来的不一样啊 oc代码如下
#pragma mark - DES加密方法

  • (NSString *) encryptUseDES:(NSString *)plainText key:(NSString *)key
    {
    NSString *ciphertext = nil;
    const char *textBytes = [plainText UTF8String];
    NSUInteger dataLength = [plainText length];
    unsigned char buffer[1024];
    memset(buffer, 0, sizeof(char));
    //const void *iv = (const void *)[gIv UTF8String];//CBC 需要才矢量
    size_t numBytesEncrypted = 0;
    CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmDES,
    kCCOptionPKCS7Padding|kCCOptionECBMode,
    [key UTF8String], kCCKeySizeDES,
    NULL,
    textBytes, dataLength,
    buffer, 1024,
    &numBytesEncrypted);
    if (cryptStatus == kCCSuccess) {
    NSData *data = [NSData dataWithBytes:buffer length:(NSUInteger)numBytesEncrypted];
    ciphertext = [[NSString alloc] initWithData:[GTMBase64 encodeData:data] encoding:NSUTF8StringEncoding];
    }
    return ciphertext;
    }

@OctMon
Copy link
Owner

OctMon commented Feb 9, 2022

image

我这边没问题的

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

我试了你的工程的 是没问题 但是引入包就有问题,我也感觉奇怪

@OctMon
Copy link
Owner

OctMon commented Feb 9, 2022

用Swfit写吧

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

工程中是des_ecb PKCS7Padding 不知道为啥和你的加密出来不一样

@OctMon
Copy link
Owner

OctMon commented Feb 9, 2022

对照着 http://tool.chacuo.net/cryptdes 这个,选一样的方式,看看结果

@qllqll
Copy link
Author

qllqll commented Feb 9, 2022

我和网站加密出来是一样的 只是偏移量没有 填充是PKCS7Padding
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@qllqll @OctMon and others