如何在DART中转换此习惯的解密Python代码?

发布于 2025-02-11 03:54:57 字数 320 浏览 2 评论 0原文

我试图获得防火墙遮盖的晦涩的电子邮件。 我在Python中找到了解决方案,但我不知道要在飞镖或颤动中这样做。 这是Python代码

    r = int(encodedString[:2],16)
    email = ''.join([chr(int(encodedString[i:i+2], 16) ^ r) for i in range(2, len(encodedString), 2)])
    return email

print cfDecodeEmail('543931142127353935313e352e7a373b39') # usage


i am trying to get obscured email that was obscured by firewall.
i found the solution in python but i don't know to do this in dart or flutter.
here is the python code

    r = int(encodedString[:2],16)
    email = ''.join([chr(int(encodedString[i:i+2], 16) ^ r) for i in range(2, len(encodedString), 2)])
    return email

print cfDecodeEmail('543931142127353935313e352e7a373b39') # usage


如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画尸师 2025-02-18 03:54:57
  • 在python中,encodedString [:2]/encodedstring [i:i+2]encodedString中提取两个字符。飞镖等效(假设ASCII字符)将是encodedString.substring(0,2)encodedString(i,i,i + 2)

  • 等效于Python的''。join(list) in Dart是list.join()。。

  • python列表综合的等效物([i in quote in quote])中的dart是collection- for :[for(for for(项目中的var I) )i]

  • 在范围内(2,len(encodedString),2)在dart中,

    python的等效是使用基本for loop, loop with start,witch,corditi和增量:for(var i = 2; i< encodedString.length; i += 2)

  • 在python中,int(String,16) parses 字符串作为十六进制数字。在DART中,使用int.parse(字符串,radix:16)

  • 在python中,chr(integer)从指定的代码点创建一个字符串。飞镖中的等效物为string.fromcharcode(integer)

将所有这些放在一起:

String cfDecodeEmail(String encodedString) {
  var r = int.parse(encodedString.substring(0, 2), radix: 16);
  var email = [
    for (var i = 2; i < encodedString.length; i += 2)
      String.fromCharCode(
        int.parse(encodedString.substring(i, i + 2), radix: 16) ^ r,
      )
  ].join();
  return email;
}

void main() {
  // Prints: [email protected]
  print(cfDecodeEmail('543931142127353935313e352e7a373b39'));
}
  • In Python, encodedString[:2]/encodedString[i:i+2] extract two characters from encodedString. The Dart equivalent (assuming ASCII characters) would be encodedString.substring(0, 2) and encodedString(i, i + 2) respectively.

  • The equivalent of Python's ''.join(list) in Dart is list.join().

  • The equivalent of a Python's list comprehensions ([i for i in items]) in Dart is collection-for: [for (var i in items) i].

  • The equivalent of Python's for i in range(2, len(encodedString), 2) in Dart is to use a basic for loop with a start, condition, and increment: for (var i = 2; i < encodedString.length; i += 2).

  • In Python, int(string, 16) parses string as a hexadecimal number. In Dart, use int.parse(string, radix: 16).

  • In Python, chr(integer) creates a string from the specified code point. The equivalent in Dart is String.fromCharCode(integer).

Putting it all together:

String cfDecodeEmail(String encodedString) {
  var r = int.parse(encodedString.substring(0, 2), radix: 16);
  var email = [
    for (var i = 2; i < encodedString.length; i += 2)
      String.fromCharCode(
        int.parse(encodedString.substring(i, i + 2), radix: 16) ^ r,
      )
  ].join();
  return email;
}

void main() {
  // Prints: [email protected]
  print(cfDecodeEmail('543931142127353935313e352e7a373b39'));
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文